【问题标题】:comparing user's input to a list in Python将用户的输入与 Python 中的列表进行比较
【发布时间】:2016-03-16 08:53:40
【问题描述】:

如何检查列表中是否有某些内容? 这是我当前的代码:

for line not in line: open("drivers_details.txt"):
               if reg not in line:
                  name=input("what is your name?\n")
                  address=input("what is your address\n")
                  print (reg,name,address,"%0.2f"%average_time,"MPH")

(我试过用“not in”但没用)

【问题讨论】:

标签: python list


【解决方案1】:

我想你想要:

for line in open("drivers_details.txt"):
    if reg not in line:
        etc.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    • 2017-01-30
    • 2022-11-01
    相关资源
    最近更新 更多