python 时间记录

last_monday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 7)).strftime(“%Y-%m-%d”)
last_tuesday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 6)).strftime(“%Y-%m-%d”)
last_wednesday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 5)).strftime(“%Y-%m-%d”)
last_thursday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 4)).strftime(“%Y-%m-%d”)
last_friday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 3)).strftime(“%Y-%m-%d”)
last_saturday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 2)).strftime(“%Y-%m-%d”)
last_sunday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 1)).strftime(“%Y-%m-%d”)
this_monday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday + 0)).strftime(“%Y-%m-%d”)
this_tuesday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday - 1)).strftime(“%Y-%m-%d”)
last_tuesday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday - 2)).strftime(“%Y-%m-%d”)
last_wednesday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday - 3)).strftime(“%Y-%m-%d”)
last_thursday = (datetime.datetime.today() - datetime.timedelta(days=time.localtime().tm_wday - 4)).strftime(“%Y-%m-%d”)

你可能感兴趣的:(python)