国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python str字符串轉uuid實例

瀏覽:101日期:2022-08-04 15:26:38

uuid str int 之間的轉換

import uudi #str 轉 uuiduuid.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 轉 uuiduuid.UUID(int=0x12345678123456781234567812345678)#Out:UUID(’12345678-1234-5678-1234-567812345678’) #uuid 轉 strstr(uuid.uuid4())#Out:’a0565f88-b20a-4cc1-a6de-11f046bb7100’type(str(uuid.uuid4()))#Out:strpython的uuid模塊提供UUID類和函數uuid1(), uuid3(), uuid4(), uuid5() 來生成1, 3, 4, 5各個版本的UUIDuuid.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) #字符串轉timet = 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)

結果:

python str字符串轉uuid實例

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實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 岳阳市| 铁岭市| 五常市| 开封市| 鄂伦春自治旗| 夏河县| 博客| 固始县| 汉中市| 富平县| 秀山| 台东市| 临清市| 成都市| 紫金县| 萨嘎县| 井陉县| 肃南| 东平县| 云南省| 白沙| 威远县| 建水县| 亚东县| 荥阳市| 远安县| 荥阳市| 屯门区| 和田县| 红安县| 九台市| 岫岩| 九龙坡区| 眉山市| 通道| 同江市| 贵州省| 和政县| 页游| 明水县| 通河县|