java郵箱判斷合法正則表達式 python正則表達式辨別輸入日期規(guī)范?
python正則表達式辨別輸入日期規(guī)范?1. Python正則表達式的輸入日期規(guī)范如下:year,month,day=Eval(input(“please input year,month,day,s
python正則表達式辨別輸入日期規(guī)范?
1. Python正則表達式的輸入日期規(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é)果: