I have to make a program that measures the size of a given directory by using recursivity. I need to use the OS module. When I used
os.path.getsize()
The response was 0 bytes, which makes no sense.
I have to make a program that measures the size of a given directory by using recursivity. I need to use the OS module. When I used
os.path.getsize()
The response was 0 bytes, which makes no sense.
You need to mention the path in the argument of a getsize function. So it would look like:
os.path.getsize(<path_of_file>)
If you are doing that already and interested in the size of a folder, you can add size of the files in the folder iteratively.
sum(os.path.getsize(f) for f in os.listdir(<path_of_the_folder>) if os.path.isfile(f))
I get your question, the same problem i also got, you can visit here for ans : https://github.com/ASHWIN990/sizeof/blob/master/sizeof
I have made a Pythton script which find the size of file and directories recurcively