[英]'builtin_function_or_method' object is not iterable' error in python search?
I am trying to write a search function on python, that searches for a customer ID in a database (for a login feature) here is the code:我正在尝试在 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,))
results = c.fetchall # fetches all of the ID's not just one
for row in results:
forename1 = (column[1])
Anytime I try and run this i keep getting this error:每当我尝试运行它时,我都会收到此错误:
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
How do i fix this?我该如何解决? any help would be gladly apprecaited任何帮助都会很高兴
Try adding parens:尝试添加括号:
results = c.fetchall()
You're assigning the method when you should be running the method and assigning what it returns.当您应该运行该方法并分配它返回的内容时,您正在分配该方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.