week_day = {"m":"星期一","tu":"星期二","w":"星期三",
"th":"星期四","f":"星期五","sa":"星期六","su":"星期日"}
fir_let = input("Please input the first letter: ")
if week_day.get(fir_let):
print('通过%s判断是%s'%(fir_let,week_day.get(fir_let)))
else:
if fir_let not in ['t','s']:
print('通过输入的第一个字母未查找到对应的星期号')
else:
sec_let =input("Please input the second letter: ")
if week_day.get(fir_let+sec_let):
print('通过%s判断是%s'%(fir_let+sec_let,week_day.get(fir_let+sec_let)))
else:
print('通过输入的2个字母未查找到')
09.输入一个字母判断是星期几,如果第一个字母相同就判断第二个字(dict.get()的用法)
猜你喜欢
转载自blog.csdn.net/weixin_43851795/article/details/86517531
今日推荐
周排行