Python3 標準庫:calendar
- 2020 年 1 月 17 日
- 筆記
- javascript
1.calendar
import calendar print(calendar.month(2008,8)) #某個月 print(calendar.calendar(2008)) #某年 print(calendar.isleap(2008)) #是否閏年 print(calendar.leapdays(1900,2008)) #兩個年份之間存在幾個閏年 print(calendar.monthcalendar(2008,8)) #返回周一到周日的列表 print(calendar.monthrange(2008,8)) #返回一個元組(4,31)代表該月從周五開始,共31天 print(calendar.weekday(2008,8,8)) #輸入日期,返回周幾
2.time
import time print(time.time()) #輸出當前時間戳 print(time.localtime()) #輸出當前本地時間元組 print(time.ctime()) #輸出當前時間,默認參數是當前時間戳 print(time.strftime('%y,%m,%d,%H,%M,%S')) #年月日時分秒 time.sleep(5) #睡眠5秒