[英]Parameters, Unpacking and variables - Learn python the hard way ex 13
I'm stuck at this point. 我被困在这一点上。 here is the code:
这是代码:
from sys import argv
script, first, second, third = argv
print "The script is called:", script
print "The first variable is:", first
print "The second variable is:", second
print "The third variable is:", third
my problem is this, when I run it I get: 我的问题是,当我运行它时,我得到:
value error need more than one value to unpack
值错误需要多个值才能解压
as far as I can see I have three values and the code is good, could someone explain where I am going wrong please. 据我所知,我有三个值并且代码很好,有人可以解释我要去哪里了。
So, in chat @Ricky troubleshooted his way to successfully determining that argv
was splitting on 因此,在聊天中,@ Ricky对成功确定
argv
分裂的方式进行了故障排除 whitespace and not
,
comma . 空白 ,而不是
,
逗号 。 Changing his command line params from 从更改他的命令行参数
$python myprog.py one,two,three
to 至
$python myprog.py one two three
made everything fine. 一切都很好。
For those who wish to learn the mysteries of the argparse . 对于那些希望了解argparse之谜的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.