您好我是新來的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