如何使用 Python 生成一串位?

pythonprogramming更新于 2023/10/30 21:17:00

您可以使用 random 模块的 getrandbits 函数生成给定大小的随机位串,该函数接受一定数量的位作为参数。 

示例

import random
hash = random.getrandbits(128)
print(hex(hash))

输出

这将给出输出 −

0xa3fa6d97f4807e145b37451fc344e58c

相关文章