';内置函数或方法';对象不可编辑';python搜索出错?
我试图在python上编写一个搜索函数,用于在数据库中搜索客户ID(用于登录功能),代码如下:';内置函数或方法';对象不可编辑';python搜索出错?,python,search,typeerror,Python,Search,Typeerror,我试图在python上编写一个搜索函数,用于在数据库中搜索客户ID(用于登录功能),代码如下: def search_ID(): import sqlite3 # imports SQlite library new_db = sqlite3.connect('LightningParties.db') c = new_db.cursor() c.execute("SELECT * FROM Customer_Details WHERE ID=?",(CustomerIDSave,))
def search_ID():
import sqlite3 # imports SQlite library
new_db = sqlite3.connect('LightningParties.db')
c = new_db.cursor()
c.execute("SELECT * FROM Customer_Details WHERE ID=?",(CustomerIDSave,))
results = c.fetchall # fetches all of the ID's not just one
for row in results:
forename1 = (column[1])
每当我尝试运行此操作时,都会出现以下错误:
File "F:/stuff that actually works/customer_login.py", line 29, in search_ID
for row in results: TypeError:
'builtin_function_or_method' object is not iterable
我该如何解决这个问题?如果您有任何帮助,请尝试添加参数:
results = c.fetchall()
当您应该运行方法并分配方法返回的内容时,您正在分配方法。提示:当您有一条错误消息引用行号时,请指示它引用的已发布代码的哪一行。