[python3] torndb中的itertools.zip[AttributeError: module 'itertools' has no attribute 'izip']

在python3中,使用torndb进行查询时,遇到问题 AttributeError: module 'itertools' has no attribute 'izip',解决该问题过程中耗费了不少时间,故把解决办法写下以便以后遇到该问题的人能更快速的解决:

因为python3中filter,map,zip本身就已经是generator了,所以torndb中的138行用到itertools.izip就显得有点多余了,所以需要改一下该代码,把return [Row(itertools.izip(column_names, row)) for row in cursor] 改为 return[Row(zip(column_names, row))for row in cursor],再运行程序,问题得到解决

猜你喜欢

转载自www.cnblogs.com/simplezhuo/p/9811369.html