简体   繁体   English

python搜索中的'builtin_function_or_method'对象不可迭代'错误?

[英]'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.

相关问题 Python'builtin_function_or_method'对象不是可迭代错误 - Python 'builtin_function_or_method' object is not iterable error 在 Z3-Python 中,执行 model 搜索时,我得到“builtin_function_or_method' object is not iterable” - In Z3-Python, I get "builtin_function_or_method' object is not iterable" when performing model search 'builtin_function_or_method' object 不可迭代 - 'builtin_function_or_method' object is not iterable 'builtin_function_or_method' 对象不是 Python 中的可订阅错误 - 'builtin_function_or_method' object is not subscriptable Error in Python Python错误:AttributeError:'builtin_function_or_method'对象没有属性 - Python Error: AttributeError: 'builtin_function_or_method' object has no attribute python错误:类型为“ builtin_function_or_method”的对象没有len() - python error: object of type 'builtin_function_or_method' has no len() python错误:builtin_function_or_method对象无法下标 - python error:builtin_function_or_method object is unsubscriptable TypeError: 'builtin_function_or_method' object is not subscriptable error in python 3 - TypeError: 'builtin_function_or_method' object is not subscriptable error in python 3 使用 os.walk 不可迭代 builtin_function_or_method' 对象 - builtin_function_or_method' object is not iterable using os.walk 显示TypeError:'builtin_function_or_method'对象在Odoo中不可迭代 - showing TypeError: 'builtin_function_or_method' object is not iterable in Odoo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM