设为首页 加入收藏

TOP

Python求crc32值的方法
2015-02-02 14:27:50 来源: 作者: 【 】 浏览:12
Tags:Python crc32 方法

在Python代码中求CRC值,要import binascii
binascii.crc32(v) 求出了v的crc32值,这是一个long型,形如-1456387L,把这个值&0xffffffff得到的值形如48a213L的形式。


例子:


def _crc32(self, v):
"""
Generates the crc32 hash of the v.
@return: str, the str value for the crc32 of the v
"""
return '0x%x' % (binascii.crc32(v) & 0xffffffff) #取crc32的八位数据 %x返回16进制


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Python函数嵌套的例子 下一篇Python单链表实例分享

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: