1 import hashlib 2 import time 3 4 size = 2048 5 md5 = hashlib.md5() 6 start = time.time() 7 with open(‘ubuntu-18.04-desktop-amd64.iso‘, ‘rb‘) as f: 8 a = f.read(2048) 9 md5.update(a) 10 while len(a) > 0: 11 # print(a) 12 a = f.read(2048) 13 md5.update(a) 14 large = len(a)+large 15 end = time.time() 16 print(‘md5: %s:‘ %md5.hexdigest()) 17 print(‘该文件大小: %sKb:‘ % size/1024) 18 print(‘所用的时间:%s:‘ % end - start)
原文地址:https://www.cnblogs.com/anc7/p/10009231.html
时间: 2024-10-05 18:54:04