1import os
2
3# get size in bytes
4path = 'path/to/file.txt'
5size = os.path.getsize(path)
1import os
2the_file_that_you_Want_to_check_the_size = os.path.getsize("The file Name")
3print(the_file_that_you_Want_to_check_the_size)
4# Your result #
1import os
2filepath='file1.txt'
3size=os.path.getsize(filepath)
4print(str(size) + ' Bytes')
5
1>>> from pathlib import Path
2>>> Path('somefile.txt').stat()
3#OUTPUT:
4os.stat_result(st_mode=33188, st_ino=6419862, st_dev=16777220, st_nlink=1, st_uid=501, st_gid=20, st_size=1564, st_atime=1584299303, st_mtime=1584299400, st_ctime=1584299400)
5
6>>> Path('somefile.txt').stat().st_size
7#OUTPUT:
81564
9