我在與我的這部分代碼的問題:
蟒蛇 - 打破嵌套條件的原始圈頂部
if(input not in status_list):
print("Invalid Entry, try again.")
break
斷裂退出整個程序,我只是想回去程序(至的開始,而(1):)
我試圖通,繼續回想不出別的..誰能幫助? 謝謝:)
此外它閱讀本浮動收入爲字符串仍然..:income = int(input("Enter taxable income: "))
該錯誤消息我得到的是「類型錯誤:‘海峽’對象不是可調用的」
import subprocess
status_list = ["s","mj","ms","h"]
while(1):
print ("\nCompute income tax: \n")
print ("Status' are formatted as: ")
print ("s = single \n mj = married and filing jointly \n ms = married and filing seperately \n h = head of household \n q = quit\n")
input = input("Enter status: ")
if(input == 'q'):
print("Quitting program.")
break
if(input not in status_list):
print("Invalid Entry, try again.")
break
income = int(input("Enter taxable income: "))
income.replace("$","")
income.replace(",","")
#passing input to perl files
if(input == 's'):
subprocess.call("single.pl")
elif(input == 'mj'):
subprocess.call("mj.pl", income)
elif(input == 'ms'):
subprocess.call("ms.pl", income)
else:
subprocess.call("head.pl", income)
風格上,應避免周圍的條件括號你的'if's和'while's(即'while 1:'而不是'while(1):','如果輸入=='s':'而不是'if(input =='s') :'......) – nneonneo 2013-02-28 20:14:27
'continue'應該按照你想要的來做。 – 2013-02-28 20:15:42
很難理解'繼續'是如何失敗的 – cnicutar 2013-02-28 20:15:45