Python生成唯一ID----UUID
# UUID 生成唯一ID # uuid 是Python内置模块,主要有五种算法。 import uuid # uuid1() 基于时间戳 a1 = uuid.uuid1() print(‘uuid1():‘, a1) # uuid2() 基于分布式计算环境DCE(Python中没有这个函数方法) # uuid3() 基于名字的MD5散列值 a3 = uuid.uuid3(uuid.NAMESPACE_DNS, ‘test_hy‘) print(‘uuid3():‘, a3) # uuid4() 基于随机数 a4 = uuid.uuid4() print(‘uuid4():‘, a4) # uuid5() 基于名字的 SHA-1 散列表 a5 = uuid.uuid5(uuid.NAMESPACE_DNS, ‘test_hy‘) print(‘uuid5():‘, a5)
结果:
uuid1(): 4a21bb4e-a15a-11ea-88b3-408d5ccd099d uuid3(): 837dd986-4fae-31bd-b696-e68327c9598c uuid4(): 9f0628b9-af93-4712-94d2-6164ec52181c uuid5(): d5083fa9-eddf-54e5-b485-a30e01a3a906
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16