1. 通过使用md5字符串比较2个文件

import hashlib
def get_file_md5(filename):
    '''可以比较两个文件的md5值,来比较文件内容。未使用'''
    md5 = hashlib.md5()
    f = open(filename, 'rb')
    while True:
        b = f.read(8096)
        if not b:
            break
        md5.update(b)
    f.close()
    return md5.hexdigest()

 

python3

import filecmp
# true if 2 files are the same
result = filecmp.cmp(file1, file2)

 

相关文章:

  • 2022-12-23
  • 2021-05-26
  • 2021-12-16
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-09
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
相关资源
相似解决方案