蓝桥杯python组——猜生日 import os import sys import datetime start = datetime . date ( 1912 , 3 , 12 ) end = datetime . date ( 2012 , 3 , 12 ) add = datetime . timedelta ( 1 ) while start = end : start += add if int ( str ( start
蓝桥杯python组——猜生日
import sys
import datetime
start=datetime.date(1912,3,12)
end=datetime.date(2012,3,12)
add=datetime.timedelta(1)
while start<=end:
start+=add
if int(str(start)[:10].replace('-',''))%2012==0 and \
int(str(start)[:10].replace('-',''))%3==0 and \
int(str(start)[:10].replace('-',''))%12==0 and start.month==6:
print(int(str(start)[:10].replace('-','')))
break
#一开始输出的结果是有57岁了,有点不太相信,应该是大明不是小明了
注:代码中的\代表换行,一行写不开。。。。。
答案为19550604
谢谢大家的支持,您的一键三连是 罡罡同学前进的最大动力!