成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

python輸入年月日輸出星期幾 Python:輸入年月日判斷是此年的第多少天?

Python:輸入年月日判斷是此年的第多少天?[import datetimey=int(input(“please input 4-digital year:”)“get yearm=int(inp

Python:輸入年月日判斷是此年的第多少天?

[import datetime

y=int(input(“please input 4-digital year:”)“get year

m=int(input(“please input month:”)“get month

d=int(input(“please input which day:”)“get day

targetday=datetime.date日期(年,月,d) #將輸入的日期格式化為標(biāo)準(zhǔn)日期

daycount=targetday-datetime.date日期( targetDay.year公司-1,12,31)#減去上一年的最后一天

打?。?s是%s年的第%s天?!?(targetDay,ydayCount.days天))

今年是2011年。如果輸入2011并按enter鍵,日期將直接顯示。如果您輸入2011,將顯示完整日期。另外,用ALT-shift d直接輸入日期,用ALT-shift輸入當(dāng)前時間

1。Python正則表達(dá)式的輸入日期規(guī)范如下:

year,month,day=Eval(input(“please input year,month,day,separated by comma”)

months=[31,28,31,30,31

]if(year%4==0 and year  0!=0)或(年@0==0):

months[1]=29#在閏年,二月最多有29天

如果month<1或month>12:

print(“非法月”

elif day<1或day>months[month 1

]print(“非法日”

否則:

print(“合法月/日”

2。代碼:

3。結(jié)果: