在Python中使用命令行参数:了解sys.argv
问题内容:
我目前正在学习困难的方式学习Python。我认为该示例可能已过时,因此我想在此获得反馈。
我正在使用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
知道有什么问题吗?
问题答案: