這篇文章給大家介紹python的時間語句有哪些呢 ,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)站營銷推廣、網(wǎng)站開發(fā)設(shè)計,對服務(wù)成都柴油發(fā)電機等多個行業(yè)擁有豐富的網(wǎng)站建設(shè)及推廣經(jīng)驗。創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司成立于2013年,提供專業(yè)網(wǎng)站制作報價服務(wù),我們深知市場的競爭激烈,認真對待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發(fā)展進步,是我們永遠的責(zé)任!
def getCurrentSec(self): return time.time()-8*60*60 def getCurrentDate(self): ISOTIMEFORMAT='%Y-%m-%d' return time.strftime(ISOTIMEFORMAT, time.localtime(time.time())) def getCurrentTime(self): ISOTIMEFORMAT='%X' return time.strftime(ISOTIMEFORMAT, time.localtime(time.time())) def getCurrentDateTime(self): ISOTIMEFORMAT='%Y-%m-%d %X' #將本地時間轉(zhuǎn)換為世界時 return time.strftime(ISOTIMEFORMAT, time.localtime(time.time()-8*60*60)) def string2Time(self, s): ISOTIMEFORMAT='%Y-%m-%d %X' return time.strptime( s, ISOTIMEFORMAT ) def Time2ISOString(self, s): ISOTIMEFORMAT='%Y-%m-%d %X' return time.strftime(ISOTIMEFORMAT, time.localtime(float(s))) ===================================================================
def GetSecondByDateTime(self, datetimeStr): # 由日期時間字符串獲取秒數(shù)(整數(shù)) ISOTIMEFORMAT='%Y-%m-%d %X' return time.mktime(time.strptime(datetimeStr, ISOTIMEFORMAT)) def GetSecondByDate(self, dateStr): # 由日期字符串獲取秒數(shù)(整數(shù)) ISOTIMEFORMAT='%Y-%m-%d' return time.mktime(time.strptime(dateStr, ISOTIMEFORMAT)) def GetTupleBySecond(self, second): # 由秒數(shù)(整數(shù)或浮點數(shù))獲得日期時間的元組,形如(年,月,日,時,分,秒,星期,天數(shù),夏令時標(biāo)志) ISOTIMEFORMAT='%Y-%m-%d %X' return time.localtime(second) def GetDateTimeBySecond(self, second): # 由秒數(shù)(整數(shù)或浮點數(shù))獲得日期時間字符串 ISOTIMEFORMAT='%Y-%m-%d %X' return time.strftime(ISOTIMEFORMAT, time.localtime(second)) def GetDateBySecond(self, second): # 由秒數(shù)(整數(shù)或浮點數(shù))獲得日期字符串 ISOTIMEFORMAT='%Y-%m-%d' return time.strftime(ISOTIMEFORMAT, time.localtime(second))
關(guān)于python的時間語句有哪些呢 就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
標(biāo)題名稱:python的時間語句有哪些呢
地址分享:http://www.js-pz168.com/article0/gcjpio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、微信公眾號、商城網(wǎng)站、App設(shè)計、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)