获取时间小技巧
-
import datetime
-
# 今天的日期
today = datetime.date.today() #2020-01-03
-
# 今天日期去掉年份
str_today = str(today)[5:] #01-03
-
# 判断今天是星期几
weekday = datetime.datetime.strptime(str(today),'%Y-%m-%d').weekday() + 1 #结果:5
-
# 获取明天日期
tomorrow = timeToday + datetime.timedelta(days=1) #2020-01-04