- 作業(yè): 輸入年齡并且將年齡值轉(zhuǎn)換成整數(shù),如果輸入錯(cuò)誤程序不崩潰信姓,讓其重新輸入祝闻,直到輸入無(wú)誤為止...
def input_age():
while True:
try:
age = int(input('請(qǐng)輸入年齡:'))
return age
except:
print('輸入錯(cuò)誤')
print(input_age())