题目链接:
https://www.lanqiao.cn/problems/103/learning/?page=1\&first_category_id=1\&name=日期问题
题目内容:
解题思路
python
import os
import sys
# 请在此输入您的代码
from datetime import datetime
date_str = input().strip()
A, B, C = map(int, date_str.split('/'))
ans = set()
def con_year(x):
if x>=60:
return x+1900
else:
return x+2000
# 年月日
try:
y = con_year(A)
dt = datetime(y, B, C)
if datetime(1960,1,1)<=dt<=datetime(2059,12,31):
ans.add(dt)
except ValueError:
pass
# 月日年
try:
y = con_year(C)
dt = datetime(y, A, B)
if datetime(1960,1,1)<=dt<=datetime(2059,12,31):
ans.add(dt)
except ValueError:
pass
# 日月年
try:
y = con_year(C)
dt = datetime(y, B, A)
if datetime(1960,1,1)<=dt<=datetime(2059,12,31):
ans.add(dt)
except ValueError:
pass
# print(ans)
for dt in sorted(ans):
print(dt.strftime("%Y-%m-%d"))