为什么我的解析器不能正确理解“ numb =”?

时间:2019-02-12 00:44:58

标签: python compiler-errors

我试图向我的WMC项目添加一个新的'NUMB =',但是它不起作用。 主要是这个

    elif Command[P] == "numb=":
         Running = "set_int"
    elif Running == "set_int" and Running == "":
        if Command[P] != "0" or Command[P] != "1" or Command[P] != "2" or Command[P] != "3" or Command[P] != "4" or Command[P] != "5" or Command[P] != "6" or Command[P] != "7"or Command[P] != ""or Command[P] != "8" or Command[P] != "9" or Command[P] != "10":
            print("The integer must not be bigger then 10, or be a string.")
            NUM = "0"
        else:
            NUM = Command[P]

而且我不明白,当我将其与“ display”命令进行比较时,我没有发现任何错误。参见:

elif Command[P] == "display" and Running == "":
    Running = "display"
elif Running == "display":
    print(Command[P])

我试图比较它们并自己调试错误。现在没有python错误,但无法按照我想要的方式工作。

while Loop == 1:
    P += 1 
    In = input(">")
    if In == " ":
        continue
    else:
        Command.append(In)
    if Command[P] == "END()":
        if Running != "":
            Running = ""
        elif Running == "":
            print("Closing...")
            exit()
    elif Command[P] == "display" and Running == "":
        Running = "display"
    elif Running == "display":
        print(Command[P])
    elif Command[P] == " ":
        continue
    elif Command[P] == "numb=":
         Running = "set_int"
    elif Running == "set_int" and Running == "":
        if Command[P] != "0" or Command[P] != "1" or Command[P] != "2" or Command[P] != "3" or Command[P] != "4" or Command[P] != "5" or Command[P] != "6" or Command[P] != "7"or Command[P] != ""or Command[P] != "8" or Command[P] != "9" or Command[P] != "10":
            print("The integer must not be bigger then 10, or be a string.")
            NUM = "0"
        else:
            NUM = Command[P]

我期望命令将变量设置为数字字符串,但它的行为就像我没有运行命令一样。

1 个答案:

答案 0 :(得分:0)

再看看您写的内容:

return

什么时候该是真的?