1
下面的代碼之前引用局部變量 '小人' 拋出UnboundLocalError:UnboundLocalError:分配
def fetch_results(conn, sql, **bind_params):
"""
Immediately fetches the SQL results into memory
Trades memory for the ability to immediately execute another query
"""
global _log_func
try:
cur = conn.cursor()
if _log_func:
_log_func(cur, sql, bind_params)
cur.execute(sql, bind_params)
return cur.fetchall()
finally:
cur.close()
錯誤:
line 75, in fetch_results
cur.close()
UnboundLocalError: local variable 'cur' referenced before assignment
我不知道爲什麼。有人能指出我正確的方向嗎?
在哪一行是錯誤? – 2014-10-22 00:43:33
錯誤發生在cur.close() – Istvan 2014-10-22 00:46:21