uuid — UUID 对象根据 RFC 4122

源代码: Lib/uuid.py


此模块提供不可变 UUID 对象 ( UUID 类) 和函数 uuid1() , uuid3() , uuid4() , uuid5() 用于生成第 1、3、4 和 5 版的 UUID 作为指定在 RFC 4122 .

If all you want is a unique ID, you should probably call uuid1() or uuid4() 。注意, uuid1() may compromise privacy since it creates a UUID containing the computer’s network address. uuid4() creates a random UUID.

Depending on support from the underlying platform, uuid1() may or may not return a “safe” UUID. A safe UUID is one which is generated using synchronization methods that ensure no two processes can obtain the same UUID. All instances of UUID have an is_safe attribute which relays any information about the UUID’s safety, using this enumeration:

class uuid. SafeUUID

3.7 版添加。