我想要一种从 Python 中的整数获取唯一 ID 的简短唯一摘要的方法。最好是8字节。
最佳答案
a unique ID from an integer in Python
我猜你正在谈论某种哈希。
如果整数在 -2**63
和 2**63
范围内,为什么不使用整数本身
如果您需要整数作为 8 字节数组:
>>> import struct
>>> struct.pack('>q', -2**60)
'\xf0\x00\x00\x00\x00\x00\x00\x00'
>>>
关于python - Python 中的简短独特摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9752949/