Changeset 391 for python/trunk/Doc/library/uuid.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/uuid.rst
r2 r391 226 226 >>> import uuid 227 227 228 # make a UUID based on the host ID and current time228 >>> # make a UUID based on the host ID and current time 229 229 >>> uuid.uuid1() 230 230 UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') 231 231 232 # make a UUID using an MD5 hash of a namespace UUID and a name232 >>> # make a UUID using an MD5 hash of a namespace UUID and a name 233 233 >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org') 234 234 UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e') 235 235 236 # make a random UUID236 >>> # make a random UUID 237 237 >>> uuid.uuid4() 238 238 UUID('16fd2706-8baf-433b-82eb-8c7fada847da') 239 239 240 # make a UUID using a SHA-1 hash of a namespace UUID and a name240 >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name 241 241 >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org') 242 242 UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d') 243 243 244 # make a UUID from a string of hex digits (braces and hyphens ignored)244 >>> # make a UUID from a string of hex digits (braces and hyphens ignored) 245 245 >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}') 246 246 247 # convert a UUID to a string of hex digits in standard form247 >>> # convert a UUID to a string of hex digits in standard form 248 248 >>> str(x) 249 249 '00010203-0405-0607-0809-0a0b0c0d0e0f' 250 250 251 # get the raw 16 bytes of the UUID251 >>> # get the raw 16 bytes of the UUID 252 252 >>> x.bytes 253 253 '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' 254 254 255 # make a UUID from a 16-byte string255 >>> # make a UUID from a 16-byte string 256 256 >>> uuid.UUID(bytes=x.bytes) 257 257 UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
Note:
See TracChangeset
for help on using the changeset viewer.