【问题标题】:Inputs not triggering if statments in python [closed]输入未触发python中的if语句[关闭]
【发布时间】:2019-01-10 19:01:41
【问题描述】:

我一直在研究一个 Python 老式计算机系统,但当我运行代码时,输​​入不会触发下一行代码。这是代码:

correctPassword = "testpassword"
guess = ""
guesses = ""
query = ""
run = 1
datacmd = ""
newfilename = ""
newtext = ""
filename = ""
appendtext = ""
helpcmd = ""
helpdcmd = ""
gameselect = ""
import time
import random
import datetime

while guess != correctPassword:
    guess = input("Password: ")

print ("loging in")

time.sleep(5)
print("Login complete.")
time.sleep(0.5)

while query == "":
    input("Please select one of the following queries by typing it into the box. data, helpme, games, date, close.")
    query = input
    #data section. read, write and edit files here
if query == "data":
        print("Welcome to data. For information on how to use your data section visit the help page.")
        input("command:")

具体的行是 if 查询行。有人知道为什么会这样吗?

【问题讨论】:

  • 如果你搜索“Python 输入教程”这个短语,你会发现比我们在这里的答案更能解释它的资源。

标签: python if-statement input


【解决方案1】:

你不能那样做query = input。它必须是query = input("Please select...")。它应该匹配上面的guess = input("Password: ")

【讨论】:

  • 好的,感谢您的帮助!我非常感谢它:)
猜你喜欢
  • 2014-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-06
  • 1970-01-01
  • 1970-01-01
  • 2021-10-23
相关资源
最近更新 更多