gpt4 book ai didi

python - 类型错误 : 'NoneType' object has no attribute '__getitem__' tkinter error

转载 作者:行者123 更新时间:2023-11-30 21:59:49 25 4
gpt4 key购买 nike

我在这里遇到的问题是,每当我尝试将数据输入我的用户名输入框 (self.KUEntry.get()) 并在我的查询中运行该输入框时,它返回 none 并抛出问题中列出的错误。

该函数应该检查注册用户存储的 salt 和哈希值,并将其与他们在输入框中输入的密码进行比较。

def login_verification(self):

username = self.KUEntry.get()
print username

cursor1.execute = ("SELECT salt FROM User WHERE username = (%s)", username)
salty = cursor1.fetchone() [0]
print salty

cursor2.execute = ("SELECT PashHash FROM User WHERE username = %s", (username))
hashy = cursor2.fetchone() [0]
print hashy

test = hashlib.sha512(username + salty).hexdigest
print test

if test == hashy:
self.mainscreen
else:
print "incorrect password"

最佳答案

像这样放置我的代码可以修复回溯错误,但它不会返回预期的结果。而不是我的 cursor1.fetchone 和 cursor2.fetchone 方法返回查询结果,它们返回“无”。

def login_verification(self):

username = self.KUEntry.get()
print username

cursor1.execute = ("SELECT salt FROM User WHERE username = %s", str(username))
salty = str(cursor1.fetchone())
print salty

cursor2.execute = ("SELECT PashHash FROM User WHERE username = %s", str(username))
hashy = str(cursor2.fetchone())
print hashy

test = hashlib.sha512(username + str(salty)).hexdigest
print test

if test == hashy:
self.mainscreen
else:
print "incorrect password"

关于python - 类型错误 : 'NoneType' object has no attribute '__getitem__' tkinter error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43751328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com