python datetime 日期相减方法
作者:互联网
import datetime
def pre_date(days=0, base_day=None):
if base_day:
base_day = base_day.strftime('%Y-%m-%d')
else:
base_day = datetime.datetime.now().strftime('%Y-%m-%d')
return datetime.datetime.strptime(base_day,
'%Y-%m-%d') - datetime.timedelta(days=days)
print(pre_date(-1))
标签:-%,pre,相减,python,days,datetime,base,day 来源: https://www.cnblogs.com/gina11/p/14830474.html