Python代码不执行多个if语句

时间:2016-08-08 03:09:41

标签: python if-statement

我不明白我的代码有什么问题,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")

1 个答案:

答案 0 :(得分:0)

input在python3中返回一个字符串,因此必须将其显式转换为int

OpCode = int(input(Prompt))