import calendar
from datetime import datetime, timedelta
while True:
today = input("输入今天日期(月日)")
today_date = datetime.strptime(today, "%Y%m%d")
if today_date.weekday() - calendar.FRIDAY > 0:
this_friday = today_date - timedelta(days=(today_date.weekday() - calendar.FRIDAY))
print(this_friday.strftime("%Y%m%d"))
else:
last_firday = today_date - timedelta(days=(today_date.weekday() - calendar.FRIDAY + 7))
print(last_firday.strftime("%Y%m%d"))