The python uuid module USES instances

  • 2020-05-07 19:56:13
  • OfStack

uuid is a one-only identifier used as an identifier in many fields. The uuid module of python is used to generate it.
In addition, python provides four methods to generate uuid, which are:

1. Generate from hardware address and time
2. Generated from md5 algorithm
3. Random generation
4. Generated from SHA-1 algorithm

They correspond to uuid1, uuid3, uuid4, uuid5 in the uuid module, but not uuid2.
Here's an example:


#-*- encoding: gb2312 -*-
import uuid print uuid.uuid1()
print uuid.uuid3(uuid.NAMESPACE_DNS, 'testme')
print uuid.uuid4()
print uuid.uuid5(uuid.NAMESPACE_DNS, 'testme')


Related articles: