Python正在检测正确的语法错误

问题描述 投票:-2回答:1

[我正在观看有关如何制作视频游戏的YouTube教程,现在我们将其转换为exe,这是我将游戏转换为exe的设置代码(不是游戏的代码本身:]

import cx_Freeze

executables = [cx_Freeze.Executable("pygame sentdex.py")]

cx_Freeze.setup(
    name="A bit racey",
    options={"build_exe": {"packages":["pygame"],
                           "include_files":["car.png"]}} #if you have other included files put them here. like fonts.
    executables = executables)

当我尝试转换时,会发生这种情况:

    PS C:\Users\Damon Tattersfield\Desktop\video game\code\python codes> python setup.py build
  File "setup.py", line 9
    executables = executables)
    ^
SyntaxError: invalid syntax
PS C:\Users\Damon Tattersfield\Desktop\video game\code\python codes>

[它一直说executables中的e是错误的,即使它对于YouTuber来说也很好,并且我将其更改为大写e,然后删除并重新输入,但是当我输入时,这是语法错误。 99%的人肯定不是。

这是YouTuber的链接:https://www.youtube.com/watch?list=PLQVvvaa0QuDdLkP8MrOXLe_rKuf6r80KO&v=EY6ZCPxqEtM

我该如何解决?谢谢...

python pygame cx-freeze
1个回答
2
投票

您需要在第二个关键字参数后添加逗号:

cx_Freeze.setup(
    name="A bit racey",
    options={"build_exe": {"packages":["pygame"],
                           "include_files":["car.png"]}}, # <-- HERE
    executables = executables)

[通常,当您得到一个SyntaxError时,解释器会告诉您该错误在第9行,而该错误实际上是缺少逗号,括号或第8行的引号。

此外,只要您遇到异常/错误,您就从不“正确”。我可以向您保证,译员不会错误地告诉他们。

© www.soinside.com 2019 - 2024. All rights reserved.