python模块之uuid
时间:2008-08-24 来源:dier
uuid是一种唯一标识,在许多领域作为标识用途。python的uuid模块就是用来生成它的。
闲话不说,python提供的生成uuid的方法一共有4种,分别是:
1.从硬件地址和时间生成
2.从md5算法生成
3.随机生成
4.从SHA-1算法生成
他们在uuid模块里对应uuid1, uuid3, uuid4, uuid5这几个方法,注意没有uuid2。
下面是示例:
#-*- encoding: gb2312 -*-
import uuid

print uuid.uuid1()
print uuid.uuid3(uuid.NAMESPACE_DNS, 'testme')
print uuid.uuid4()
print uuid.uuid5(uuid.NAMESPACE_DNS, 'testme')

来自:http://blog.csdn.net/zhaoweikid/archive/2007/06/12/1649786.aspx
闲话不说,python提供的生成uuid的方法一共有4种,分别是:
1.从硬件地址和时间生成
2.从md5算法生成
3.随机生成
4.从SHA-1算法生成
他们在uuid模块里对应uuid1, uuid3, uuid4, uuid5这几个方法,注意没有uuid2。
下面是示例:









来自:http://blog.csdn.net/zhaoweikid/archive/2007/06/12/1649786.aspx
相关阅读 更多 +