蓝桥杯Python赛道中,如何编写程序来猜中特定选手的生日?

2026-05-26 18:341阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计235个文字,预计阅读时间需要1分钟。

蓝桥杯Python赛道中,如何编写程序来猜中特定选手的生日?

蓝桥杯Python组——猜生日pythonimport osimport sysimport 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)[5:7])==int(input()): print(str(start)[:10]) break


蓝桥杯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)[: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

谢谢大家的支持,您的一键三连是 罡罡同学前进的最大动力!



蓝桥杯Python赛道中,如何编写程序来猜中特定选手的生日?

本文共计235个文字,预计阅读时间需要1分钟。

蓝桥杯Python赛道中,如何编写程序来猜中特定选手的生日?

蓝桥杯Python组——猜生日pythonimport osimport sysimport 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)[5:7])==int(input()): print(str(start)[:10]) break


蓝桥杯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)[: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

谢谢大家的支持,您的一键三连是 罡罡同学前进的最大动力!



蓝桥杯Python赛道中,如何编写程序来猜中特定选手的生日?