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

时间:2012-12-03 06:02:06

标签: mysql python-2.7 mysql-python

我有这段代码应该从db返回密码的值,并将其与输入的密码相匹配。我在此行上添加了字符以匹配其打印结果的格式。

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

即使两个打印出相同的值,if语句拒绝它并且总是落到其他地方,任何人都可以指向正确的路径吗?

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"

1 个答案:

答案 0 :(得分:1)

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