鱼C论坛

 找回密码
 立即注册
查看: 17235|回复: 121

[技术交流] Python:每日一题 4

[复制链接]
发表于 2020-2-24 23:13:41 | 显示全部楼层
number=[0,31,28,31,30,31,30,31,31,30,31,30,31]
temp=input('请输入日期(格式如:2000.02.08):')
temp=list(temp)
temp.reverse()
year=''
month=''
day=''
while temp[-1]!='.':
    year+=str(temp.pop())
temp.pop()
while temp[-1]!='.':
    month+=str(temp.pop())
temp.pop()
month=int(month)
print(month)
while temp:
    day+=str(temp.pop())
year=int(year)
month=int(month)
day=int(day)
if (year%100==0)and(year%100==0):
    flag=1
elif (year%4==0)and(year%100!=0):
    flag=1
else :
    flag=0
i=range(month)
if month<=2:
    num=0
    for each in i:
        num+=number[each]
    num+=day
elif (2<month<=12):
    num=flag
    for each in i:
        num+=number[each]
    num+=day
print("%d月%d日是%d年的第%d天"%(month,day,year,num))
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-9-27 08:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表