如何获取所有子目录和文件的列表以及按大小升序排列的大小?
下面的代码让我得到所有文件的列表,但没有根据大小排序。请帮忙。
import os
import os.path, time
from os.path import join, getsize
count=0
for root, dirs, files in os.walk('Test'):
for file in list(files):
fileaddress = os.path.join(root, file)
print("\nName:",fileaddress)
print("Time:",time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fileaddress))))
count=count+1
print(count);