在Python中搜索然后验证

时间:2015-10-19 20:06:25

标签: python csv

我希望能够在Python中搜索.csv文件中的用户ID,然后验证密码是否与用户ID匹配。任何我出错的建议都将不胜感激

到目前为止

代码!

1 个答案:

答案 0 :(得分:0)

如果ID在标题ID下

passwd = input("please enter you id ")

with open("data.csv", 'r') as f:
        r = csv.DictReader(f, delimiter=',')
        for row in r:
            # skips the headers without next
            if row['id'] == passwd:
                print("the Id is valid")