ITeye博客

2016 年文章归档

共 1 篇文章

用Python写了个文件夹比较的脚本

import os import hashlib def md5sum(filename): fd = open(filename,"r") fcont = fd.read() fd.close() fmd5 = hashlib.md5(fcont) return fmd5.hexdigest() dir1='/home/a' dir2='/home/b' for rt,dirs,files in os.walk(dir1): for f in files: f1 = os.path.join(rt,f) if not os.path.exists(f1): continue if f1.f…

2016-07-16 14:08 · python