【发布时间】:2015-09-03 17:33:26
【问题描述】:
我知道如何找到文件的校验和:
# Print checksum of the file
file = os.popen("md5sum -t " + indir + "/" + binfile)
checksum = file.read().split(' ')[0]
print "Checksum of " + binfile + " is " + checksum
但是,校验和是一个 32 个字符的字符串。
现在,我想将此校验和转换为 16 个字符的字符串,这样每个字符将代表校验和中的 2 个字符(例如,“63”将是 ascii 字符 0x63)。
我该怎么做?
【问题讨论】:
-
旁注:不要使用
os.popen。它自 Python 2.6 起已被弃用。
标签: python-2.7 md5sum