【发布时间】:2015-12-23 03:28:36
【问题描述】:
我已经有了这个代码。现在我想更改代码,当有人输入他的用户名时,他必须填写属于该用户名的正确密码。
import csv
csvbestand='inlog.csv'
csv = open('inlog.csv', 'r').read().split('\n')[1].split(';')
username= input("Fill in your username: ")
if username == "admin" or username in csv:
print("Username found")
break
else:
print("Username not found")
while True:
import csv
csvbestand='inlog.csv'
csv = open('inlog.csv', 'r').read().split('\n')[2].split(';')
password = input("Fill in your password: ")
if password == "admin" or password in csv:
print("Congratiulations")
break
else:
print("Password not right")
所以当用户名是“John”时,我只想要属于“John”的密码作为正确的密码。
【问题讨论】:
-
您至少需要向我们展示 csv 文件并解释您的代码到底有什么问题。 (说“它不工作”是不够的。)
-
你的问题不清楚。