1import os
2
3def get_size(start_path = '.'):
4 total_size = 0
5 for dirpath, dirnames, filenames in os.walk(start_path):
6 for f in filenames:
7 fp = os.path.join(dirpath, f)
8 # skip if it is symbolic link
9 if not os.path.islink(fp):
10 total_size += os.path.getsize(fp)
11
12 return total_size
13
14print(get_size(), 'bytes')