我收到以下错误:
if 'ShazK01' in LogRef.values():
AttributeError: 'list' object has no attribute 'values'
运行后:
import pymysql
db = pymysql.connect(host='localhost', ..)
cur = db.cursor()
def getData():
LoginInput=[]
InputUN = ('ShazK01')
InputPC = ('passinput')
LoginInput=[InputUN, InputPC]
return LoginInput
def checkExistence():
cur = db.cursor(pymysql.cursors.DictCursor)
cur.execute("SELECT Username FROM LoginDetails")
LogRef = cur.fetchall() #fetch ALL login references
print(LogRef)
if 'ShazK01' in LogRef.values():
print("yes")
else:
print("no")
LoginInput = getData()
print(LoginInput)
print(LoginInput[0])
UNInput = LoginInput[0]
print(UNInput)
checkExistence()
我查看了其他答案,但它们没有帮助。因此,感谢任何有用的建议,因为我是同时使用 sql 和 python 的初学者,谢谢!