ValueError: Too Many Values to Unpack Aptana Studio 3

梦想与她 提交于 2019-12-25 00:24:55

问题


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?


回答1:


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.




回答2:


in the script window, right click, ShowIn > Terminal. It will open a terminal window in Aptana. Then type, python 'your script'.py That will run in way you want I think; Rather with the visual you want.



来源:https://stackoverflow.com/questions/12575870/valueerror-too-many-values-to-unpack-aptana-studio-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!