We are working on Python code in the window environment.
Depending on the size of the file, I'm working on a different code (such as writing an e-mail if it's over 100 kb) I can do everything else, but I don't know the function to find out the size of the file. Where can I find related functions?
python file size
os.stat(path) returns the stat structure for that path. For information on stat structure, see This answer
import os
mystat = os.stat("myfile.JSON") #
print("mystat :", mystat)
mysize = mystat.st_size
print("mysize :", mysize)
Result:
mystat : os.stat_result(st_mode=33188, st_ino=2465615, st_dev=16777220, st_nlink=1, st_uid=501, st_gid=20, st_size=211, st_atime=1452665170, st_mtime=1452665170, st_ctime=1452665170)
mysize : 211
import os
mysize = os.path.getsize("myfile.JSON")
print("mysize :", mysize)
Result: mysize: 211
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
914 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.