我收到关于文件“<stdin>”第 1 行的语法错误

Ser*_*tae -3 python syntax-error

这是错误,我不知道错误在哪里:

> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe  
"c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
  File "<stdin>", line 1
    & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
    ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 6

你得到一个 PythonSyntaxError是因为你试图在 Python shell 中运行一个 PowerShell 命令:

>>> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
Run Code Online (Sandbox Code Playgroud)

exit退出该外壳,然后在 PowerShell 中运行您的 PowerShell 命令。提示应该看起来像

PS C:\>
Run Code Online (Sandbox Code Playgroud)

Python shell 用于以交互方式运行代码,例如,您可以输入类似的内容import pygameprint("Hello, world!")直接输入其中的内容。