對Python來說很新穎,我使用2.7來編寫腳本。我該如何循環這個
a = raw_input("Input number or decimal only")
Try:
Y = float(a)
print a
except ValueError:
print "wrong input, try again"
我需要循環 - 如果輸入是字母數字或字母,它應該再次要求輸入。
我似乎無法找到一種方法在它的while循環中滑動。
(Python的新手,請善待!)
有沒有中 '休息'你複製粘貼你的代碼或重新輸入它?因爲這個代碼不會運行。 – idjaw
你有沒有嘗試用'while True:'塊封裝整個事物? –