神剑山庄资源网 Design By www.hcban.com
uuid str int 之间的转换
import uudi #str 转 uuid uuid.UUID('12345678123456781234567812345678') uuid.UUID(hex='12345678123456781234567812345678') uuid.UUID('{12345678-1234-5678-1234-567812345678}') uuid.UUID('urn:uuid:12345678-1234-5678-1234-567812345678') #Out:UUID('12345678-1234-5678-1234-567812345678') uuid.UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)) #Out:UUID('12345678-1234-5678-1234-567812345678') #int 转 uuid uuid.UUID(int=0x12345678123456781234567812345678) #Out:UUID('12345678-1234-5678-1234-567812345678') #uuid 转 str str(uuid.uuid4()) #Out:'a0565f88-b20a-4cc1-a6de-11f046bb7100' type(str(uuid.uuid4())) #Out:str python的uuid模块提供UUID类和函数uuid1(), uuid3(), uuid4(), uuid5() 来生成1, 3, 4, 5各个版本的UUID uuid.uuid1([node[, clock_seq]]) : 主机ID, 序列号, 和时间戳来生成UUID, 可保证全球范围的唯一性 uuid.uuid3(namespace, name) : 基于命名空间和名字的MD5散列值 uuid.uuid4() : 基于随机数 uuid.uuid5(namespace, name) : 基于命名空间和名字的SHA-1散列值,同uuid3
补充拓展:python字符串和time互转与时间的加减另加uuid
咱们看代码吧!
# -*-coding:utf-8 -*- __author__ = "ZJL" import uuid,time,datetime #uuid4产生32位随机字母加数字 print(str(uuid.uuid4()).replace("-","")) #uuid3产生基于名字的MD5散列值 print(str(uuid.uuid3(uuid.NAMESPACE_DNS,"username")).replace("-","")) #time转字符串 time_num = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) print(time_num) #字符串转time t = time.strptime(time_num, '%Y-%m-%d %H:%M:%S') y,m,d,H,M,S = t[:6] print(t) print(datetime.datetime(y,m,d,H,M,S)) #时间的加减 now_time = datetime.datetime.now() #当前时间加半小时 yes_time = now_time + datetime.timedelta(hours=+0.5) #比较时间大小 if now_time>yes_time: print("ok") else: print("no") #当前时间减一天 # yes_time = now_time + datetime.timedelta(days=-1) yes_time_nyr = yes_time.strftime('%Y-%m-%d %H:%M:%S') print(yes_time_nyr)
结果:
import time, datetime #一个月前 today1 = datetime.datetime.today() astmonth = datetime.datetime(today1.year, (today1.month - 1), today1.day, today1.hour, today1.minute,today1.second)
以上这篇python str字符串转uuid实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无python str字符串转uuid实例的评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年10月03日
2024年10月03日
- 孙悦.1996-伙伴【正大国际】【WAV+CUE】
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】