2016-08-08 62 views
0

我不明白我的代碼有什麼問題,if語句被跳過,請幫助我。Python代碼不執行多個if語句

import sys 

print("-_-_-_-_-_-_-_-_-_-_-_-_- T Data Analysis Pro -_-_-_-_-_-_-_-_-_-_-_-_-\n\n"); 

OpCode = 1 
while OpCode != 0: 
    Prompt = "Enter your desired Operation:\n" \ 
     "0 : Exit\n" \ 
     "1 : Read T Data File\n" \ 
     "2 : Provide Analysis on an Item\n" \ 
     "TDA >> " 
    OpCode = input(Prompt) 
    print("\n[Debug] Input = ",OpCode,"\n") 
    if OpCode == 0: 
     print("Bye!") 
     break 
    if OpCode == 1: 
     filename = input("\nEnter target filename to parse:") 
     print("\n***************** Not Implemented ******************\n") 
    if OpCode == 2: 
     itemname = input("\nEnter Item Name: ") 
     print("\n *********************** You Just Wait .... ************************\n") 

回答

0

輸入返回python3一個字符串,所以你必須明確地將其轉換爲int

OpCode = int(input(Prompt))