新聞中心
這篇文章主要介紹calendar在python3時(shí)間中常用函數(shù)有哪些以及使用示例,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)主營(yíng)長(zhǎng)清網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開發(fā)公司,長(zhǎng)清h5小程序開發(fā)搭建,長(zhǎng)清網(wǎng)站營(yíng)銷推廣歡迎長(zhǎng)清等地區(qū)企業(yè)咨詢
1.firstweekday()
firstweekday(): 返回當(dāng)前每周起始日期值。默認(rèn)情況下,首次載入calendar模塊時(shí)返回0,即星期一
import calendar # 0 print(calendar.firstweekday())
2.setfirstweekday()
setfirstweekday(firstweekday) :通過(guò)常量 MONDAY、TUESDAY、WEDNESDAY、THURSDAY、FRIDAY、SATURDAY 和 SUNDAY 設(shè)置星期;其中 0 表示星期一,以此類推6表示星期日;
import calendar calendar.setfirstweekday(calendar.SUNDAY) # 6 print(calendar.firstweekday())
3. isleap()
isleap(year):判斷是否是閏年,閏年為True,平年為False
import calendar # False print(calendar.isleap(2018)) # True print(calendar.isleap(2016))
4.leapdays()
leapdays(y1, y2): 返回[y1,y2)年份之間的閏年數(shù)量;
import calendar # 2 print(calendar.leapdays(2012, 2020))
以上是calendar在python3時(shí)間中常用函數(shù)有哪些以及使用示例的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
標(biāo)題名稱:calendar在python3時(shí)間中常用函數(shù)有哪些以及使用示例
標(biāo)題鏈接:http://fisionsoft.com.cn/article/gcceds.html