我收到关于文件“<stdin>",第 1 行的语法错误 [英] I get a syntax error about File &quot;&lt;stdin&gt;&quot;, line 1

查看:30
本文介绍了我收到关于文件“<stdin>",第 1 行的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

<代码>>&C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exec:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"文件<stdin>",第 1 行&C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"^语法错误:无效语法

解决方案

你得到一个 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 退出该 shell,然后在 PowerShell 中运行您的 PowerShell 命令.提示应该类似于

PS C:\>

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

This is the error, I have no idea where the fault is:

> & 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

解决方案

You're getting a Python SyntaxError because you are trying to run a PowerShell command in the Python shell:

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

exit out of that shell and then run your PowerShell command in PowerShell. The prompt should look something like

PS C:\>

The Python shell is for running code interactively, e.g. you could type something like import pygame or print("Hello, world!") directly into it.

这篇关于我收到关于文件“<stdin>",第 1 行的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆