我正在API中使用Python。API是使用Javascript编写的,我不知道在Python中这一行的等效代码是如何实现的:
crypto.randomBytes(8).join("")我发现了这个链接https://docs.python.org/3/library/uuid.html,但我不知道如何才能得到完全相同的结果。
谢谢你的帮助
发布于 2022-10-27 17:14:54
尝试:
from random import randint
bytes([randint(0, 255) for _ in range(8)])编辑:如果您需要安全的随机字节:
from secrets import token_bytes
token_bytes(8)https://stackoverflow.com/questions/73665311
复制相似问题