How to create a GUID/UUID in Python

前端 未结 8 1097
情话喂你
情话喂你 2020-11-22 16:47

How do I create a GUID in Python that is platform independent? I hear there is a method using ActivePython on Windows but it\'s Windows only because it uses COM. Is there a

8条回答
  •  旧巷少年郎
    2020-11-22 17:17

    If you're using Python 2.5 or later, the uuid module is already included with the Python standard distribution.

    Ex:

    >>> import uuid
    >>> uuid.uuid4()
    UUID('5361a11b-615c-42bf-9bdb-e2c3790ada14')
    

提交回复
热议问题