在python中使用命令行时的语法错误

在python中使用命令行时的语法错误

本文介绍了在python中使用命令行时的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python的初学者,目前在使用命令行时遇到问题。我有一个脚本test.py(它只包含 printHello。),它位于地图C:\Python27。在我的系统变量,我已经指定python是C:\Python27(我有其他版本的Python安装在我的电脑上)。

I am a beginner to python and am at the moment having trouble using the command line. I have a script test.py (which only contains print "Hello."), and it is located in the map C:\Python27. In my system variables, I have specified python to be C:\Python27 (I have other versions of Python installed on my computer as well).

我认为这应该足够在命令行中运行 python test.py ,但是当我这样做时,我得到:

I thought this should be enough to run python test.py in the command line, but when I do so I get this:

File "<stdin>", line 1
python test.py
       ^
SyntaxError: invalid syntax

有什么问题?提前感谢!

What is wrong? Thanks in advance!

推荐答案

看起来你的问题是你试图运行 python test.py

Looks like your problem is that you are trying to run python test.py from within the Python interpreter, which is why you're seeing that traceback.

这篇关于在python中使用命令行时的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 15:54