from datetime import datetime, date, timedelta
begin_date=date.today()+timedelta(days=-2) #美国当前日期6.1
begin_str=str(begin_date)
begin14_date = date.today()-timedelta(days=16)#14天前日期
begin14_str = str(begin14_date)
while begin_str>begin14_str:
begin_date=begin_date+timedelta(days=-1)
begin_str = str(begin_date)
print(begin_str)
运行结果
![[47F69VS~OP6E6FWLX1QP5.png
网友评论