我是 python 新手,我想练习一下,try/except但我卡住了:
def monitor():
try:
brightness = int(input("brightness:"))
except ValueError:
print("please pass in a number")
if brightness < -1 or brightness > 101:
print("invaild",brightness)
else:
print("invalid",brightness)
while True:
monitor()
我希望输入字符串时不会出现错误,但它给了我:
UnboundLocalError
眼眸繁星
largeQ
RISEBY
相关分类