标签:not hashlib dig ret file iges ash turn type
遍历file的方式
iter(lambda: f.read(4096), "")
等价与
while True:
data = f.read(4096)
if not data:
break
hash_md5.updata(data)
# 生成md5 def get_file_md5(fname): hash_md5 = hashlib.md5() with open(fname, "rb") as f: print type(f) for chunk in iter(lambda: f.read(4096), ""): hash_md5.update(chunk) return base64.b64encode(hash_md5.digest())
标签:not hashlib dig ret file iges ash turn type
原文地址:http://www.cnblogs.com/bierxiaobia/p/6434555.html