我目前正在通过学习Python The Hard Way。我认为这个例子可能过时了,所以我想在这里得到反馈。在Python中使用命令行参数:理解sys.argv
我使用Python 3.1
from sys import argv
script, first, second, third = argv
print("the script is called:", (script))
print("your first variable is:", (first))
print("your second variable is:", (second))
print("your third variable is:", (third))
我得到这个错误:
Traceback (most recent call last):
File "/path/ch13.py", line 3, in <module>
script, first, second, third, bacon = argv
ValueError: need more than 1 value to unpack
任何想法有什么不对?
我是小白,什么是这样做的代码我已经写了正确的方法是什么? – 2011-01-21 23:59:32
`foo.py bar baz quux` – 2011-01-22 00:00:21