我有下面的函数,我正试图在while True:
循环中调用它:
def icaolist():
c = conn3.cursor()
c.execute("SELECT * FROM icaolist")
rows = c.fetchall()
result = {}
for row in rows:
result[row[0]] = row[1]
return result
上面的函数在循环外工作得很好,但当我试图把它放在循环内时,我得到了以下错误:
TypeError: 'dict' object is not callable
我用这个来称呼它:
while True:
icaolist = icaolist()
time.sleep(60)
icaolist = icaolist()
字典和函数不能有相同的名称。