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

时间:2019-12-27 19:21:31

标签: python syntax-error

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

  

&C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe
  “ c:/ Users / tanel / Documents / Projects / Coding / Python / Game Alien / game.py”     文件“”,第1行       &C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe“ c:/ Users / tanel / Documents / Projects / Coding / Python / Game Alien / game.py”       ^   SyntaxError:语法无效

1 个答案:

答案 0 :(得分:0)

您正在获取Python SyntaxError,因为您试图在Python shell中运行PowerShell命令:

>>> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"

exit脱离该外壳,然后在PowerShell中运行PowerShell命令。提示应类似于

C:\>

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