IdentifiantMot de passe
Mot de passe oublié ?Je m'inscris ! (gratuit)
18.16.1 Example

18.16.1 Example

Here are some examples of typical usage of the uuid module:

>>> import uuid

# make a UUID based on the host ID and current time
>>> uuid.uuid1()

# make a UUID using an MD5 hash of a namespace UUID and a name
>>> uuid.uuid3(uuid.NAMESPACE_DNS, '')

# make a random UUID
>>> uuid.uuid4()

# make a UUID using a SHA-1 hash of a namespace UUID and a name
>>> uuid.uuid5(uuid.NAMESPACE_DNS, '')

# make a UUID from a string of hex digits (braces and hyphens ignored)
>>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')

# convert a UUID to a string of hex digits in standard form
>>> str(x)

# get the raw 16 bytes of the UUID
>>> x.bytes

# make a UUID from a 16-byte string
>>> uuid.UUID(bytes=x.bytes)
See About this document... for information on suggesting changes.