python獲取當(dāng)日剩余時間理张,毫秒值剩彬、秒
今天寫代碼因?yàn)闃I(yè)務(wù)需要浮庐,計算了截止到目前當(dāng)日剩余時間唁奢,網(wǎng)上這方面的資料比較少霎挟,發(fā)出來供大家參考
import datetime
import time
def rest_of_day():
"""
:return: 截止到目前當(dāng)日剩余時間
"""
today = datetime.datetime.strptime(str(datetime.date.today()), "%Y-%m-%d")
tomorrow = today + datetime.timedelta(days=1)
nowTime = datetime.datetime.now()
return (tomorrow - nowTime).microseconds # 獲取毫秒值
return (tomorrow - nowTime).seconds # 獲取秒
return (tomorrow - nowTime).min # 獲取分鐘
if __name__ == '__main__':
print(rest_of_day())
運(yùn)行結(jié)果:
88723
23887