树莓派 / 电脑研究

Python 中 try 的用法

a=0
while a<1:
    try:
        a=a+1
        number=int(raw_input("What is the number?"))
    except:
        print "Error!Please enter a number!"
        a=a-1

写于 2015/11/03 · Krunk Zhou

一起聊聊