TypeError: list indices must be integers or slices, not str when trying to convert .py file to .exe with cx_Freeze
TypeError: list indices must be integers or slices, not str when trying to convert .py file to .exe with cx_Freeze
所以基本上我正在尝试使用 cx_Freeze 将 python 文件转换为可执行文件。我一直收到错误消息
TypeError: list indices must be integers or slices, not str
在尝试构建它时,我不知道是什么原因造成的。谁能给我一些帮助?错误在第 8 行,带有 "include_file"
的部分。但是我不确定这条线有什么问题。非常感谢您的帮助。
import cx_Freeze
executables = [cx_Freeze.Executable("Consumo V23.py")]
cx_Freeze.setup(
name="A bit Racey",
options={"build_exe": {"packages":["pygame"],
"include_files":["Blowfish.png"]["dojo.png"]["Rice_fresh.png"]["rottenapple.png"]["rottenfish.png"]["rottenrice.png"]
["menu screen .png"]["gameover.png"]["Apple .png"]["Fish.png"]}},
executables = executables
)
我想象这条线
options={"build_exe": {"packages":["pygame"],
"include_files":["Blowfish.png"]["dojo.png"]["Rice_fresh.png"]["rottenapple.png"]["rottenfish.png"]["rottenrice.png"]
["menu screen .png"]["gameover.png"]["Apple .png"]["Fish.png"]}}
应该是
options={"build_exe": {"packages":["pygame"],
"include_files":["Blowfish.png", "dojo.png", "Rice_fresh.png", "rottenapple.png", "rottenfish.png", "rottenrice.png", "menu screen.png", "gameover.png", "Apple .png", "Fish.png"]}}
两个相邻的列表不会连接(就像字符串一样),列表后面的方括号是列表索引,因此 ["foo"]["bar"]
试图使用 "bar"
作为索引来获取列表 ["foo"]
.
中的一项
所以基本上我正在尝试使用 cx_Freeze 将 python 文件转换为可执行文件。我一直收到错误消息
TypeError: list indices must be integers or slices, not str
在尝试构建它时,我不知道是什么原因造成的。谁能给我一些帮助?错误在第 8 行,带有 "include_file"
的部分。但是我不确定这条线有什么问题。非常感谢您的帮助。
import cx_Freeze
executables = [cx_Freeze.Executable("Consumo V23.py")]
cx_Freeze.setup(
name="A bit Racey",
options={"build_exe": {"packages":["pygame"],
"include_files":["Blowfish.png"]["dojo.png"]["Rice_fresh.png"]["rottenapple.png"]["rottenfish.png"]["rottenrice.png"]
["menu screen .png"]["gameover.png"]["Apple .png"]["Fish.png"]}},
executables = executables
)
我想象这条线
options={"build_exe": {"packages":["pygame"],
"include_files":["Blowfish.png"]["dojo.png"]["Rice_fresh.png"]["rottenapple.png"]["rottenfish.png"]["rottenrice.png"]
["menu screen .png"]["gameover.png"]["Apple .png"]["Fish.png"]}}
应该是
options={"build_exe": {"packages":["pygame"],
"include_files":["Blowfish.png", "dojo.png", "Rice_fresh.png", "rottenapple.png", "rottenfish.png", "rottenrice.png", "menu screen.png", "gameover.png", "Apple .png", "Fish.png"]}}
两个相邻的列表不会连接(就像字符串一样),列表后面的方括号是列表索引,因此 ["foo"]["bar"]
试图使用 "bar"
作为索引来获取列表 ["foo"]
.