1. 導入hashlib模塊 import hashlib 2. 打開文件并讀取內(nèi)容 with open('file.txt', 'rb') as f: content = f.read() 3. 計算MD5值 md5 = hashlib.md5(content).hexdigest()
完整代碼如下:
import hashlib
with open('file.txt', 'rb') as f:
content = f.read()
md5 = hashlib.md5(content).hexdigest()
print(md5)
其中,'file.txt'為要獲取MD5值的文件路徑。文章源自網(wǎng)吧系統(tǒng)維護-http://hvig.cn/10599.html 文章源自網(wǎng)吧系統(tǒng)維護-http://hvig.cn/10599.html
版權聲明:文章圖片資源來源于網(wǎng)絡,如有侵權,請留言刪除!!!


評論