我试图在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]

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

最佳答案

再看看您写的内容:

elif Running == "set_int" and Running == "":

什么时候会是真的?

关于python - 为什么我的解析器无法正确理解 “numb=”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54641235/

10-11 18:06