python学习笔记之傻瓜错误

Alex posted @ 2011年8月25日 23:51 in python , 1557 阅读

代码来自可爱的python 

 

# -*- coding: utf-8 -*-
import os,sys
CDROM ='e:\windows'
def cdWalker(cdrom,cdcfile):
    export=""
    for root,dirs,files in os.walk(cdrom):
        export+="\n %s;%s;%s" % (root,dirs,files)
    open(cdcfile,'w').write(export)
#cdWalker('e:\windows','cd1.cdc')
if "-e"==sys.argv[1]:
    cdWalker(CDROM,sys.argv[2])
    print "记录光盘信息到 %s" %sys.argv[2]
else:
    print '''PyCDC使用方式:
    python pycdc.py -e mycd1-1.cdc
    #将光盘内容记录为mycd1-1.cdc
    '''

然后先前我设置了环境变量,结果就直接cmd下执行python e:\pycdc1.py -e e:\mycd1.cdc

后来一次不小心关掉cmd之后,我想起了Python(command line) 打开之后我输入了同样的命令

 

>>> python e:\pycdc1.py -e e:\mycd1.cdc
  File "<stdin>", line 1
    python helloworld.py
                    ^
SyntaxError: invalid syntax

谷歌之

the >>> prompt indicates you are already running python interpreter.

You need to enter that command from the shell prompt.

Press Ctrl-D to exit Python to the ordinary shell prompt and try again.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter