{
    "mode": "pydoc",
    "parameter": "uuid",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/uuid/json",
    "generated": "2026-06-02T13:24:12Z",
    "sections": {
        "NAME": {
            "content": "uuid - UUID objects (universally unique identifiers) according to RFC 4122.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/uuid.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides immutable UUID objects (class UUID) and the functions",
            "subsections": [
                {
                    "name": "uuid1",
                    "content": "UUIDs as specified in RFC 4122.\n\nIf all you want is a unique ID, you should probably call uuid1() or uuid4().\nNote that uuid1() may compromise privacy since it creates a UUID containing\nthe computer's network address.  uuid4() creates a random UUID.\n\nTypical usage:\n\n>>> import uuid\n\n# make a UUID based on the host ID and current time\n>>> uuid.uuid1()    # doctest: +SKIP\nUUID('a8098c1a-f86e-11da-bd1a-00112444be1e')\n\n# make a UUID using an MD5 hash of a namespace UUID and a name\n>>> uuid.uuid3(uuid.NAMESPACEDNS, 'python.org')\nUUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')\n\n# make a random UUID\n>>> uuid.uuid4()    # doctest: +SKIP\nUUID('16fd2706-8baf-433b-82eb-8c7fada847da')\n\n# make a UUID using a SHA-1 hash of a namespace UUID and a name\n>>> uuid.uuid5(uuid.NAMESPACEDNS, 'python.org')\nUUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')\n\n# make a UUID from a string of hex digits (braces and hyphens ignored)\n>>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')\n\n# convert a UUID to a string of hex digits in standard form\n>>> str(x)\n'00010203-0405-0607-0809-0a0b0c0d0e0f'\n\n# get the raw 16 bytes of the UUID\n>>> x.bytes\nb'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f'\n\n# make a UUID from a 16-byte string\n>>> uuid.UUID(bytes=x.bytes)\nUUID('00010203-0405-0607-0809-0a0b0c0d0e0f')\n"
                }
            ]
        },
        "CLASSES": {
            "content": "builtins.object\nUUID\nenum.Enum(builtins.object)\nSafeUUID\n",
            "subsections": [
                {
                    "name": "class SafeUUID",
                    "content": "|  SafeUUID(value, names=None, *, module=None, qualname=None, type=None, start=1)\n|\n|  An enumeration.\n|\n|  Method resolution order:\n|      SafeUUID\n|      enum.Enum\n|      builtins.object\n|\n|  Data and other attributes defined here:\n|\n|  safe = <SafeUUID.safe: 0>\n|\n|  unknown = <SafeUUID.unknown: None>\n|\n|  unsafe = <SafeUUID.unsafe: -1>\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from enum.Enum:\n|\n|  name\n|      The name of the Enum member.\n|\n|  value\n|      The value of the Enum member.\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties inherited from enum.EnumMeta:\n|\n|  members\n|      Returns a mapping of member name->value.\n|\n|      This mapping lists all enum members, including aliases. Note that this\n|      is a read-only view of the internal mapping.\n"
                },
                {
                    "name": "class UUID",
                    "content": "|  UUID(hex=None, bytes=None, bytesle=None, fields=None, int=None, version=None, *, issafe=<SafeUUID.unknown: None>)\n|\n|  Instances of the UUID class represent UUIDs as specified in RFC 4122.\n|  UUID objects are immutable, hashable, and usable as dictionary keys.\n|  Converting a UUID to a string with str() yields something in the form\n|  '12345678-1234-1234-1234-123456789abc'.  The UUID constructor accepts\n|  five possible forms: a similar string of hexadecimal digits, or a tuple\n|  of six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and\n|  48-bit values respectively) as an argument named 'fields', or a string\n|  of 16 bytes (with all the integer fields in big-endian order) as an\n|  argument named 'bytes', or a string of 16 bytes (with the first three\n|  fields in little-endian order) as an argument named 'bytesle', or a\n|  single 128-bit integer as an argument named 'int'.\n|\n|  UUIDs have these read-only attributes:\n|\n|      bytes       the UUID as a 16-byte string (containing the six\n|                  integer fields in big-endian byte order)\n|\n|      bytesle    the UUID as a 16-byte string (with timelow, timemid,\n|                  and timehiversion in little-endian byte order)\n|\n|      fields      a tuple of the six integer fields of the UUID,\n|                  which are also available as six individual attributes\n|                  and two derived attributes:\n|\n|          timelow                the first 32 bits of the UUID\n|          timemid                the next 16 bits of the UUID\n|          timehiversion         the next 16 bits of the UUID\n|          clockseqhivariant    the next 8 bits of the UUID\n|          clockseqlow           the next 8 bits of the UUID\n|          node                    the last 48 bits of the UUID\n|\n|          time                    the 60-bit timestamp\n|          clockseq               the 14-bit sequence number\n|\n|      hex         the UUID as a 32-character hexadecimal string\n|\n|      int         the UUID as a 128-bit integer\n|\n|      urn         the UUID as a URN as specified in RFC 4122\n|\n|      variant     the UUID variant (one of the constants RESERVEDNCS,\n|                  RFC4122, RESERVEDMICROSOFT, or RESERVEDFUTURE)\n|\n|      version     the UUID version number (1 through 5, meaningful only\n|                  when the variant is RFC4122)\n|\n|      issafe     An enum indicating whether the UUID has been generated in\n|                  a way that is safe for multiprocessing applications, via\n|                  uuidgeneratetimesafe(3).\n|\n|  Methods defined here:\n|\n|  eq(self, other)\n|      Return self==value.\n|\n|  ge(self, other)\n|      Return self>=value.\n|\n|  getstate(self)\n|\n|  gt(self, other)\n|      Return self>value.\n|\n|  hash(self)\n|      Return hash(self).\n|\n|  init(self, hex=None, bytes=None, bytesle=None, fields=None, int=None, version=None, *, issafe=<SafeUUID.unknown: None>)\n|      Create a UUID from either a string of 32 hexadecimal digits,\n|      a string of 16 bytes as the 'bytes' argument, a string of 16 bytes\n|      in little-endian order as the 'bytesle' argument, a tuple of six\n|      integers (32-bit timelow, 16-bit timemid, 16-bit timehiversion,\n|      8-bit clockseqhivariant, 8-bit clockseqlow, 48-bit node) as\n|      the 'fields' argument, or a single 128-bit integer as the 'int'\n|      argument.  When a string of hex digits is given, curly braces,\n|      hyphens, and a URN prefix are all optional.  For example, these\n|      expressions all yield the same UUID:\n|\n|      UUID('{12345678-1234-5678-1234-567812345678}')\n|      UUID('12345678123456781234567812345678')\n|      UUID('urn:uuid:12345678-1234-5678-1234-567812345678')\n|      UUID(bytes='\\x12\\x34\\x56\\x78'*4)\n|      UUID(bytesle='\\x78\\x56\\x34\\x12\\x34\\x12\\x78\\x56' +\n|                    '\\x12\\x34\\x56\\x78\\x12\\x34\\x56\\x78')\n|      UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))\n|      UUID(int=0x12345678123456781234567812345678)\n|\n|      Exactly one of 'hex', 'bytes', 'bytesle', 'fields', or 'int' must\n|      be given.  The 'version' argument is optional; if given, the resulting\n|      UUID will have its variant and version set according to RFC 4122,\n|      overriding the given 'hex', 'bytes', 'bytesle', 'fields', or 'int'.\n|\n|      issafe is an enum exposed as an attribute on the instance.  It\n|      indicates whether the UUID has been generated in a way that is safe\n|      for multiprocessing applications, via uuidgeneratetimesafe(3).\n|\n|  int(self)\n|\n|  le(self, other)\n|      Return self<=value.\n|\n|  lt(self, other)\n|      Return self<value.\n|\n|  repr(self)\n|      Return repr(self).\n|\n|  setattr(self, name, value)\n|      Implement setattr(self, name, value).\n|\n|  setstate(self, state)\n|\n|  str(self)\n|      Return str(self).\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  bytes\n|\n|  bytesle\n|\n|  clockseq\n|\n|  clockseqhivariant\n|\n|  clockseqlow\n|\n|  fields\n|\n|  hex\n|\n|  node\n|\n|  time\n|\n|  timehiversion\n|\n|  timelow\n|\n|  timemid\n|\n|  urn\n|\n|  variant\n|\n|  version\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  int\n|\n|  issafe\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "getnode",
                    "content": "Get the hardware address as a 48-bit positive integer.\n\nThe first time this runs, it may launch a separate program, which could\nbe quite slow.  If all attempts to obtain the hardware address fail, we\nchoose a random 48-bit number with its eighth bit set to 1 as recommended\nin RFC 4122.\n"
                },
                {
                    "name": "uuid1",
                    "content": "Generate a UUID from a host ID, sequence number, and the current time.\nIf 'node' is not given, getnode() is used to obtain the hardware\naddress.  If 'clockseq' is given, it is used as the sequence number;\notherwise a random 14-bit sequence number is chosen.\n"
                },
                {
                    "name": "uuid3",
                    "content": "Generate a UUID from the MD5 hash of a namespace UUID and a name.\n"
                },
                {
                    "name": "uuid4",
                    "content": "Generate a random UUID.\n"
                },
                {
                    "name": "uuid5",
                    "content": "Generate a UUID from the SHA-1 hash of a namespace UUID and a name.\n"
                }
            ]
        },
        "DATA": {
            "content": "NAMESPACEDNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8')\nNAMESPACEOID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8')\nNAMESPACEURL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8')\nNAMESPACEX500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8')\nRESERVEDFUTURE = 'reserved for future definition'\nRESERVEDMICROSOFT = 'reserved for Microsoft compatibility'\nRESERVEDNCS = 'reserved for NCS compatibility'\nRFC4122 = 'specified in RFC 4122'\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Ka-Ping Yee <ping@zesty.ca>\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/uuid.py\n\n",
            "subsections": []
        }
    },
    "summary": "uuid - UUID objects (universally unique identifiers) according to RFC 4122.",
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Generate and decode Universally Unique Identifiers (UUID).",
        "examples": [
            {
                "description": "Generate a UUIDv1 (based on time and system's hardware address, if present)",
                "command": "uuid"
            },
            {
                "description": "Generate a UUIDv4 (based on random data)",
                "command": "uuid -v {{4}}"
            },
            {
                "description": "Generate multiple UUIDv4 identifiers at once",
                "command": "uuid -v {{4}} -n {{number_of_uuids}}"
            },
            {
                "description": "Generate a UUIDv4 and specify the output format",
                "command": "uuid -v {{4}} -F {{BIN|STR|SIV}}"
            },
            {
                "description": "Generate a UUIDv4 and write the output to a file",
                "command": "uuid -v {{4}} -o {{path/to/file}}"
            },
            {
                "description": "Generate a UUIDv5 (based on the supplied object name) with a specified namespace prefix",
                "command": "uuid -v {{5}} ns:{{DNS|URL|OID|X500}} {{object_name}}"
            },
            {
                "description": "Decode a given UUID",
                "command": "uuid -d {{uuid}}"
            }
        ]
    }
}