Python - TypeError: unsupported operand type(s) for +: 'zip' and 'int'
Python - TypeError: unsupported operand type(s) for +: 'zip' and 'int'
我正在修改一些 Python 2.7 代码以与 Python 3.7 兼容。我做了尽可能多的编辑,直到发生这种情况:
C:\Users\AyazA\Desktop\schema-games>python schema_games/breakout/play.py StandardBreakout
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[34m--------------------------------------------------------------------------------[0m
[34mStarting interactive game. Press <ESC> at any moment to terminate.[0m
[34m--------------------------------------------------------------------------------[0m
Traceback (most recent call last):
File "schema_games/breakout/play.py", line 93, in <module>
play_game(getattr(games, variant), debug=debug, cheat_mode=cheat_mode)
File "schema_games/breakout/play.py", line 54, in play_game
play(env, fps=fps, keys_to_action=keys_to_action, zoom=ZOOM_FACTOR)
File "C:\Python37\lib\site-packages\gym\utils\play.py", line 79, in play
env.reset()
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\core.py", line 301, in reset
self.layout_sanity_check()
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\core.py", line 473, in layout_sanity_check
all_occupied_nzis = [nzi for obj in considered_objects
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\core.py", line 474, in <listcomp>
for nzi in obj.offset_nzis if obj.visible]
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\objects.py", line 190, in offset_nzis
offset_nzis_from_position(self._nzis, self._position)
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\utils.py", line 57, in offset_nzis_from_position
return zip(*(np.add(nzis, np.array(pos))).T)
TypeError: unsupported operand type(s) for +: 'zip' and 'int'
我尝试解压缩压缩元组的内容,但没有用。我进一步尝试研究强制两者相加(pos
和 nzis
都是 ndarray
类型),结果却不起作用。这是我遗漏的另一个 Python 2.7 不兼容问题吗? Here is the source code and the corresponding repository 我从
分叉出来的
误报。这是文件本身问题的集合。 zip
函数的许多实例需要替换为 list(zip)
。
我正在修改一些 Python 2.7 代码以与 Python 3.7 兼容。我做了尽可能多的编辑,直到发生这种情况:
C:\Users\AyazA\Desktop\schema-games>python schema_games/breakout/play.py StandardBreakout
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[34m--------------------------------------------------------------------------------[0m
[34mStarting interactive game. Press <ESC> at any moment to terminate.[0m
[34m--------------------------------------------------------------------------------[0m
Traceback (most recent call last):
File "schema_games/breakout/play.py", line 93, in <module>
play_game(getattr(games, variant), debug=debug, cheat_mode=cheat_mode)
File "schema_games/breakout/play.py", line 54, in play_game
play(env, fps=fps, keys_to_action=keys_to_action, zoom=ZOOM_FACTOR)
File "C:\Python37\lib\site-packages\gym\utils\play.py", line 79, in play
env.reset()
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\core.py", line 301, in reset
self.layout_sanity_check()
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\core.py", line 473, in layout_sanity_check
all_occupied_nzis = [nzi for obj in considered_objects
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\core.py", line 474, in <listcomp>
for nzi in obj.offset_nzis if obj.visible]
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\objects.py", line 190, in offset_nzis
offset_nzis_from_position(self._nzis, self._position)
File "C:\Users\AyazA\Desktop\schema-games\schema_games\breakout\utils.py", line 57, in offset_nzis_from_position
return zip(*(np.add(nzis, np.array(pos))).T)
TypeError: unsupported operand type(s) for +: 'zip' and 'int'
我尝试解压缩压缩元组的内容,但没有用。我进一步尝试研究强制两者相加(pos
和 nzis
都是 ndarray
类型),结果却不起作用。这是我遗漏的另一个 Python 2.7 不兼容问题吗? Here is the source code and the corresponding repository 我从
误报。这是文件本身问题的集合。 zip
函数的许多实例需要替换为 list(zip)
。