我正试图打印fetchone()值,但它只是给了我一个错误'NoneType' object is not iterable
,有人知道为什么吗
这是我的密码:
def viewemaillook():
global realusername
global realpassword
viewemail = input("Would you like to see/change your email")
if viewemail == "y" or viewemail == "yes":
c.execute("SELECT email, * FROM stuffToPlot WHERE username = ? and password = ?", (realusername,realpassword,))
grab = c.fetchone()
for i in grab:
print(i)
elif viewemail == "n" or "no":
print("Okay")
else:
print("Invalid option")
viewemaillook()
viewemaillook()
else:
print("Not a valid option")
change()
change()
如果查询没有找到任何结果,则
fetchone()
将返回None
。当你尝试在grab
上循环,它等于None
你得到了错误。请先检查grab
中是否有结果。你知道吗相关问题 更多 >
编程相关推荐