def getlogins():
from requests import get
url = "https://raw.githubusercontent.com/Ezb2661/lol/master/loginstest"
return get(url).text
logins = getlogins()
logins = logins[:-1]
username = input("Username:")
username = str(username)
password = input("Password: ")
password = str(password)
if password == logins[username]:
print("Logged in!")
else:
print("Wrong password or username")
每当我运行它时,它会提示输入用户名和密码,但它会说第15行出现错误:
TypeError: string indices must be integers
答案 0 :(得分:0)
通过将我的json格式修复为{" ezb2661":" test"}而非{" ezb2661:test"},然后使用
return loads( get(url).text )