Pyhon DateTime的模塊如何在相關(guān)類方法中的整理
以下的文章就是對Pyhon DateTime的模塊在實際應(yīng)用過程中的具體介紹,本文涉及到的Pyhon DateTime相關(guān)的類方法整理,以及其相應(yīng)的代碼詳解,希望你在看完我們的文章會有所收獲。
相關(guān)聯(lián)的模塊還有time與calendar 其中的time我們上面已經(jīng)做了整理。呆會再整理下日歷相比time模塊來講的話這個模塊在運(yùn)算上更加方便一點(diǎn)?,F(xiàn)在整理一下其幫助文檔上面的內(nèi)容出來
構(gòu)造方法:
- datetime(year,month,day,[hour[,minute[,
second[,microsecond[,tzinfo]]]]])
參數(shù)說明:
- <!--[if !supportLists]-->· <!--[endif]-->MINYEAR
<= year <= MAXYEAR- <!--[if !supportLists]-->· <!--[endif]-->1 <= month
<= 12- <!--[if !supportLists]-->· <!--[endif]-->1 <= day
<= number of days in the given month and year- <!--[if !supportLists]-->· <!--[endif]-->0
<= hour < 24- <!--[if !supportLists]-->· <!--[endif]-->0
<= minute < 60- <!--[if !supportLists]-->· <!--[endif]-->0
<= second < 60- <!--[if !supportLists]-->· <!--[endif]-->0
<= microsecond < 1000000
Pyhon DateTime相關(guān)類方法整理
1、today() 返回當(dāng)前的本地時間值
- if __name__ == '__main__':
- datetimedatetimes = datetime.datetime(2001,12,2)
構(gòu)造方法參數(shù)要指明正確哦
- print datetimes.today()
返回:
- 2010-03-04 14:40:51.783000
即為當(dāng)前的時間值了
2、
- now([tz])
示例:
- if __name__ == '__main__':
- datetimedatetimes = datetime.datetime(2001,12,2)
- print datetimes.now()
輸出:
- 2010-03-04 14:43:09.127000
如果沒指定參數(shù)即表示當(dāng)前的時間值!以上的文章就是對Pyhon DateTime的相關(guān)實際應(yīng)用方案的部分介紹。
【編輯推薦】