python - Python 中的简短独特摘要

标签 python

我想要一种从 Python 中的整数获取唯一 ID 的简短唯一摘要的方法。最好是8字节。

最佳答案

a unique ID from an integer in Python

我猜你正在谈论某种哈希。

如果整数在 -2**632**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/

相关文章:

python - 在模型 django 中的每个字段上实现隐私的最佳方式

python - 将 Python 侧模块从 Github 安装到 Anaconda

python - 减小 cPickle 对象的大小

python - 在 IronPython 中将复选框绑定(bind)到字符串

python - TypeError : int() argument must be a string or a number, 不是 'Model Instance'

python - python中小写字母排序

python - 不知道如何使用distinct() django

python - 为什么 Python 描述符会复制?

python - Apache Airflow -mysql 'Specified key was too long; max key length is 1000 bytes'

python - Django 多态树 list_display 内容字段中的对象名称