[英]Parameters, Unpacking and variables - Learn python the hard way ex 13
我被困在这一点上。 这是代码:
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
我的问题是,当我运行它时,我得到:
值错误需要多个值才能解压
据我所知,我有三个值并且代码很好,有人可以解释我要去哪里了。
因此,在聊天中,@ Ricky对成功确定argv
分裂的方式进行了故障排除 空白 ,而不是
,
逗号 。 从更改他的命令行参数
$python myprog.py one,two,three
至
$python myprog.py one two three
一切都很好。
对于那些希望了解argparse之谜的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.