gpt4 book ai didi

mysql - python-mysql fetchone() 类型不匹配?

转载 作者:行者123 更新时间:2023-11-29 14:09:53 26 4
gpt4 key购买 nike

我有这段代码应该从数据库返回密码值并将其与输入的密码进行匹配。我在这一行附加了字符以匹配其打印结果的格式。

appended_y= "(u'" + y + "'y,)"

即使两者打印出相同的值,if 语句也会拒绝它并且总是落入 else,有人能指出我正确的路径吗?

print "Welcome to the online bookstore login!"
x = raw_input('Please enter your user id. ')
y = raw_input('Please enter your password. ')
appended_y= "(u'" + y + "'y,)"
z = "SELECT password FROM members WHERE userid = %s"
self.cursor.execute(z,(x,))
pw=(self.cursor.fetchone())

if appended_y == pw:
self.member_menu()
else:
print "Incorrect name or password. Aborting connection"

最佳答案

查看pw的类型。它可能是列表或元组中的字符串。

关于mysql - python-mysql fetchone() 类型不匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13677976/

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