栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Python中生成可复制(带有种子)的随机UUID

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Python中生成可复制(带有种子)的随机UUID

差不多好了:

uuid.UUID(int=rd.getrandbits(128))

这是在以下帮助下确定的

help

>>> help(uuid.UUID.__init__)Help on method __init__ in module uuid:__init__(self, hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None) unbound uuid.UUID method    Create a UUID from either a string of 32 hexadecimal digits,    a string of 16 bytes as the 'bytes' argument, a string of 16 bytes    in little-endian order as the 'bytes_le' argument, a tuple of six    integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version,    8-bit clock_seq_hi_variant, 8-bit clock_seq_low, 48-bit node) as    the 'fields' argument, or a single 128-bit integer as the 'int'    argument.  When a string of hex digits is given, curly braces,    hyphens, and a URN prefix are all optional.  For example, these    expressions all yield the same UUID:    UUID('{12345678-1234-5678-1234-567812345678}')    UUID('12345678123456781234567812345678')    UUID('urn:uuid:12345678-1234-5678-1234-567812345678')    UUID(bytes='x12x34x56x78'*4)    UUID(bytes_le='x78x56x34x12x34x12x78x56' +       'x12x34x56x78x12x34x56x78')    UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))    UUID(int=0x12345678123456781234567812345678)    Exactly one of 'hex', 'bytes', 'bytes_le', 'fields', or 'int' must    be given.  The 'version' argument is optional; if given, the resulting    UUID will have its variant and version set according to RFC 4122,    overriding the given 'hex', 'bytes', 'bytes_le', 'fields', or 'int'.


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/653317.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号