python 2 CRC校验程序
from zlib import crc32import os
import sys
import re
def getCrc32(filename):
with open(filename, 'rb') as f:
return crc32(f.read())&0xffffffff
checksum=getCrc32(sys.argv[1])
print ('%X' %checksum)
print str(hex(checksum)).upper()
# 第二个输出,如何用正则的方法去掉0X和后面的L
运行结果如下:
python crc32.py 001.sgf
669A22FF
0X669A22FFL