标签:project pychar end file sdi har size global std
import os
path = r‘/Users/authurchen/PycharmProjects/Demo‘
# print(os.listdir(path))
ls = os.listdir(path)
files = []
def get_all_file(dir_path):
global files
for filepath in os.listdir(dir_path):
tmp_path = os.path.join(dir_path,filepath)
if os.path.isdir(tmp_path):
get_all_file(tmp_path)
else:
files.append(tmp_path)
return files
def calc_files_size(files_path):
files_size = 0
for f in files_path:
files_size += os.path.getsize(f)
return files_size
files = get_all_file(path)
print(calc_files_size(files))
标签:project pychar end file sdi har size global std
原文地址:https://www.cnblogs.com/shanau2/p/10203224.html