文件的MD5值与文件名无关,与文件的内容相关:
import hashlib
def get_file_md5(file_path):
hash_obj = hashlib.md5()
with open(file_path, 'rb') as file_obj:
while True:
b = file_obj.read(8192)
if not b:
break
hash_obj.update(b)
return hash_obj.hexdigest()