只是想知道我该如何解决这个错误?
python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
另一个例子:
python --version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not define
答案 0 :(得分:3)
命令python
在命令提示符下运行。 python
不是Python中的命令。
打开命令提示符(在Windows上名为cmd
,在OSX上名为Terminal
),然后键入您尝试使用的命令之一。
C:\>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'test'
test
>>> exit()
C:\>python --version
Python 2.7.2
C:\>
答案 1 :(得分:3)
你得到一个Python错误;这意味着你已经 in Python解释器。因此,您不需要(或甚至可以)再次执行Python可执行文件。
如果要退出解释器,请按 Ctrl + Z 和 Enter 。然后,您就可以再次致电python
或python --version
。