简体   繁体   English

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

[英]Why does my parser not understand “numb=” properly?

I tried to add a new 'NUMB=' to my WMC project but it won't work. 我试图向我的WMC项目添加一个新的'NUMB =',但是它不起作用。 Mainly this 主要是这个

    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]

and I do not understand, when I compare it to the "display" command I see nothing wrong. 而且我不明白,当我将其与“ display”命令进行比较时,我没有发现任何错误。 See: 看到:

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

I tried to compare them and debug the error myself. 我试图比较它们并自己调试错误。 Now there is no python error, but it will not work the way I want. 现在没有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]

I was expecting the command to set the variable to a string that is a number but instead it acts as if I didn't run the command. 我期望命令将变量设置为数字字符串,但它的行为就像我没有运行命令一样。

Take another look at what you wrote: 再看看您写的内容:

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

When will this ever be True? 什么时候会是真的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM