Created
May 18, 2021 03:55
-
-
Save kawakami-o3/2ae7f99cccbfa322c2cf6aa301d93c10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def get_size_dir(path='.'): | |
total_size = 0 | |
for dir_path in os.listdir(path): | |
full_path = os.path.join(path, dir_path) | |
if os.path.isfile(full_path): | |
total_size += os.path.getsize(full_path) | |
elif os.path.isdir(full_path): | |
total_size += get_size_dir(full_path) | |
return total_size | |
print(get_size_dir('.')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment