Skip to content

Instantly share code, notes, and snippets.

@hxer
Created March 10, 2016 03:10
Show Gist options
  • Save hxer/883027a4a3e651165234 to your computer and use it in GitHub Desktop.
Save hxer/883027a4a3e651165234 to your computer and use it in GitHub Desktop.
计算文件md5值
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment