import time print(time.time())
1583160214.5189838
localtime = time.localtime(time.time()) print(localtime) print(time.localtime())
time.struct_time(tm_year=2020, tm_mon=3, tm_mday=2, tm_hour=22, tm_min=48, tm_sec=23, tm_wday=0, tm_yday=62, tm_isdst=0)
time.struct_time(tm_year=2020, tm_mon=3, tm_mday=2, tm_hour=22, tm_min=48, tm_sec=23, tm_wday=0, tm_yday=62, tm_isdst=0)
时间元组是用一个元组装起来的9组数字处理时间
time.strftime()用于格式化日期
# 格式化成2020-03-02 22:47:23形式 print (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
2020-03-02 22:47:23
import calendar print(calendar.month(2020,3))
March 2020 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31