首页 > 编程语言 > 详细

Python 之 UUID

时间:2018-04-07 15:24:03      阅读:169      评论:0      收藏:0      [点我收藏+]
  • UUID是根据MAC以及当前时间等创建的不重复的随机字符串
import uuid

# Generate a UUID from a host ID, sequence number, and the current time
>>> uuid.uuid1()

# Generate a UUID from the MD5 hash of a namespace UUID and a name
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')

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

# Generate a UUID from the SHA-1 hash of a namespace UUID and a name
>>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')

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

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

Python 之 UUID

原文:https://www.cnblogs.com/linkworld/p/8733372.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!