您好,登錄后才能下訂單哦!
from datetime import datetime#導(dǎo)入模塊里面的當(dāng)前時間模塊
import time
print(dir(datetime))
now_time = datetime.now()#獲得當(dāng)前的時間
print("now:{0}".format(now_time))
print('now day:{0}'.format(now_time.date()))#將時間格式化
print('now day:{0}'.format(now_time.time()))
print('now day:{0}'.format(now_time.today()))
print('now day:{0}'.format(now_time.year))
print('now day:{0}'.format(now_time.month ))
print(dir(now_time))
print(time.time())
print("--------------------------------------------------")
#自定義時間輸出
d= datetime(2020,10,30,14,6)
#時間日期字符串之間的轉(zhuǎn)換
ds = '2018/10/3'
ds_t=datetime.strptime(ds,'%Y/%m/%d')
print(ds_t)
print("---------------------------------------------------")
n=datetime.now()
print(n)
n_str = n.strftime('%Y/%m/%d%H:%M:%S')#轉(zhuǎn)換為字符串
print(n_str)
print(type(n_str))
print("----------------------------------------------------")
#datetime之間的加減操作
n = datetime.now()
n_next =n + timedelta (days=5,hours=42,minutes=4)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。