您好我是新来的Python和当前已复制下面的脚本:的命令行参数传递蟒蛇
# filename is printer.py
import sys
for arg in sys.argv:
print arg # the zeroth element is the module name
raw_input("press any key") # a trick to keep the python console open
我想获得的参数,然后模块名称。 但运行此代码给我下面的错误:
U:\printer.py
File "U:\printer.py", line 6
print arg # zeroth element is the module name
^
SyntaxError: Invalid syntax
有谁知道什么可能是错在这里? 我使用Python 3.2
此外, “按任意键” 是骗人的,不管你是使用'raw_input'或'input'。 – geoffspear
@Woobie - 好点。它应该是“按回车”。 – mgilson