# 现在
now = datetime.datetime.now()
# 365天前
before = now - datetime.timedelta(days=365)
# 格式化
before = before.strftime('%Y-%m-%d')
datime.date
d = datetime.date.today()
print(d)
d1 = d.replace(d.year-3)
print(d1)
# 现在
now = datetime.datetime.now()
# 365天前
before = now - datetime.timedelta(days=365)
# 格式化
before = before.strftime('%Y-%m-%d')
datime.date
d = datetime.date.today()
print(d)
d1 = d.replace(d.year-3)
print(d1)
本文标题:python 日期
本文链接:https://www.haomeiwen.com/subject/ndmrwktx.html
网友评论