python计算MD5值 Posted on 2018-07-08 Views: Disqus: 计算字符串的MD5值12345import hashlibstring = ''md5 = hashlib.md5(string.encode('utf-8')).hexdigest()print(md5) 计算文件的MD5值1234567import hashlibfile = ''md5file = open(file, 'rb')md5 = hashlib.md5(md5file.read()).hexdigest()md5file.close()print(md5)