os.path.getsize(r'查询的地址')
2.寻找D盘大于500M的文件:import os mydir = r'D:\\' emit_dir ={"System Volume Information","Config.Msi","Program Files","$RECYCLE.BIN"} def findBig(dir): for fname in os.listdir(dir): sub_path = os.path.join(dir, fname) if os.path.isfile(sub_path): size =(os.path.getsize(sub_path))/1024/1024 #换算成MB if size>500: size =round(size,2) print(sub_path,":",size,"MB") elif fname not in emit_dir: findBig(sub_path) if __name__ == "__main__" : findBig(mydir)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)