请教sys.argv的用法
在《笨方法学python》第十五章的练习有:
from sys import argv
script, filename = argv
txt = open(filename)
print "Here's your file %r:" % filename
print txt.read()
print "Type the filename again:"
file_again = raw_input("> ")
txt_again = open(file_again)
print txt_again.read()
但是我在使用python 2.5 IDLE 执行到 script,filename =argv就出现问题,
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
script, filename = argv
ValueError: need more than 1 value to unpack
在google搜索了一下,没有相关的说明,麻烦帮忙指正下。谢谢
[解决办法]
python script.py arg