码迷,mamicode.com
首页 > 编程语言 > 详细

Python 之 UUID

时间:2018-04-07 16:08:42      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:dig   时间   and   time   创建   git   id3   imp   names   

  • 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

标签:dig   时间   and   time   创建   git   id3   imp   names   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!