? ? ? ?今天,使用torndb的過程中發(fā)現(xiàn)了報了下面這個錯誤,
File "C:\Python36\lib\site-packages\torndb.py", line 138, in query return [Row(itertools.izip(column_names, row)) for row in cursor] File "C:\Python36\lib\site-packages\torndb.py", line 138, inreturn [Row(itertools.izip(column_names, row)) for row in cursor]
AttributeError: module 'itertools' has no attribute 'izip'
????????查了下文檔,發(fā)現(xiàn)python3中filter,map,zip本身就已經(jīng)是generator了,所以itertools.izip就顯得有點多余了,所以也就沒有了.
只需要簡單的修改代碼就可以,
defquery(self, query, *parameters, **kwparameters):
"""Returns a row list for the given query and parameters."""
cursor =self._cursor()
try:
self._execute(cursor, query, parameters, kwparameters)
column_names = [d[0]fordincursor.description]
# return [Row(itertools.izip(column_names, row)) for row in cursor]
return[Row(zip(column_names, row))for row in cursor]
finally:
cursor.close()
