How to calculate file size in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to calculate file size in python?

while we write a coding in embedded by using python how to calculate the file size.

30th May 2018, 4:46 AM
SATHISHKUMAR V
SATHISHKUMAR V - avatar
5 Answers
+ 3
youll need access to the file itself Use os.stat, and use the st_size member of the resulting object: >>> import os >>> statinfo = os.stat('somefile.txt') >>> statinfo (33188, 422511L, 769L, 1, 1032, 100, 926L, 1105022698,1105022732, 1105022732) >>> statinfo.st_size 926L Output is in bytes. https://stackoverflow.com/questions/2104080/how-to-check-file-size-in-JUMP_LINK__&&__python__&&__JUMP_LINK
30th May 2018, 4:54 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 4
SATHISHKUMAR.V by the way you can check your file size when you open it in your desktop It will be next to it
30th May 2018, 4:56 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Depends on the number of 0s and 1s used to store your code in your C drive, etc. :/
30th May 2018, 4:55 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Thanks Brains let me try and come back to you
30th May 2018, 5:17 AM
SATHISHKUMAR V
SATHISHKUMAR V - avatar
- 1
Pegasus thank you. I know that but without desktop option how can we know the file size?
30th May 2018, 5:16 AM
SATHISHKUMAR V
SATHISHKUMAR V - avatar