Thursday, 23 September 2021

Python: Get file size

'os.path.getsize' take file path as input and return file size in bytes.

 

file_size_in_bytes.py

import os

file_path = '/Users/Shared/poi/xls/abc_org.xls'
size_in_bytes = os.path.getsize(file_path)

print('file size : ', size_in_bytes, ' bytes')

Sample Output

file size :  18944  bytes


  

Previous                                                    Next                                                    Home

No comments:

Post a Comment