国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

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)前時(shí)間

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é)果: