@Selena, You can use os.path.getsize(path) which returns the size of the path in bytes.It also raises an OSError in case, the file does not exist or is inaccessible.
import os
path = 'C:\\Python27\\Lib\\genericpath.py'
Stat_info = os.path.getsize('C:\\Python27\\Lib\\genericpath.py')
print(stat_info)
Output:
243
You can also use os.stat(path) method to give the status of the path specified:
Ex-
import os
path = 'C:\\Python27\\Lib\\genericpath.py'
Stat_info = os.stat(path)
print(stat_info)
Output:
os.stat_result(st_mode=34188, st_ino=725981, st_dev=2867, st_nlink=1, st_uid=1000,st_gid=1000, st_size=243, st_atime=15315670940, st_mtime=1630306690, st_ctime=15303487690)