猿问

为什么只有在终端中引导GASP才能正常工作?

我在终端中输入了以下命令:


br@wind:~$ python

Python 2.7.3 (default, Aug  1 2012, 05:16:07) 

[GCC 4.6.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from gasp import *

>>> begin_graphics()

>>> Closed.

br@wind:~$ touch gasp.py

br@wind:~$ echo "from gasp import *" >>  gasp.py

br@wind:~$ echo "begin_graphics()" >> gasp.py

br@wind:~$ cat gasp.py 

from gasp import *

begin_graphics()

br@wind:~$ python gasp.py

Traceback (most recent call last):

  File "gasp.py", line 1, in <module>

    from gasp import *

  File "/home/br/gasp.py", line 2, in <module>

    begin_graphics()

NameError: name 'begin_graphics' is not defined

为什么GASP仅在我直接在python shell中键入代码时运行,而在执行python脚本时却无法运行?


忽然笑
浏览 169回答 1
1回答

扬帆大鱼

常见错误,请不要使用与您使用的库相同的名称来命名程序。
随时随地看视频慕课网APP

相关分类

Python
我要回答