问题描述
我正在学习 learnpythonthehardway.org 上的练习 13.我应该运行这个代码:
from sys import argv脚本,第一,第二,第三 = argvprint "脚本被调用:", 脚本打印您的第一个变量是:",首先打印您的第二个变量是:",第二个打印您的第三个变量是:",第三个
然后在命令行输入python ex13.py first 2nd 3rd",应该输出:
脚本调用:ex13.py你的第一个变量是:第一你的第二个变量是:2nd你的第三个变量是:3rd
但是,我在 Vista 上使用 Aptana Studio 3 并且我得到了ValueError:要解压的值太多"错误.
我是 Python 和 Aptana 的新手,所以如何在此处输入单独的参数?
这是因为 len(argv)
可能大于 4:
尝试打印 argv
以查看 argv
实际包含的内容.
I am working on exercise 13 from learnpythonthehardway.org. I should run this code:
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
Then enter "python ex13.py first 2nd 3rd" on command line and should output:
The script is called: ex13.py
Your first variable is: first
Your second variable is: 2nd
Your third variable is: 3rd
However, I am using Aptana Studio 3 on Vista and I get the"ValueError: too many values to unpack" error.
I am new to Python and Aptana so how can I enter the separate arguments here?
It's because len(argv)
might be greater than 4:
>>> w,x,y,z=[1,2,3,4,5]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
Try printing argv
to see what argv
actually contains.
这篇关于ValueError:太多的值无法解压 Aptana Studio 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!