Skip to content

Instantly share code, notes, and snippets.

@PranjalDureja0002
Created May 7, 2021 13:04
Show Gist options
  • Save PranjalDureja0002/889e8b5fb6681387660dc097eadb831e to your computer and use it in GitHub Desktop.
Save PranjalDureja0002/889e8b5fb6681387660dc097eadb831e to your computer and use it in GitHub Desktop.
model
def get_file_size(file_path):
size = os.path.getsize(file_path)
return size
def convert_bytes(size, unit=None):
if unit == "KB":
return print('File size: ' + str(round(size / 1024, 3)) + ' Kilobytes')
elif unit == "MB":
return print('File size: ' + str(round(size / (1024 * 1024), 3)) + ' Megabytes')
else:
return print('File size: ' + str(size) + ' bytes')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment