阅读页面底部的FAQ,它专门提到了此错误。
常见学生问题问: 当我运行它时,我得到
ValueError: need more than 1 value to unpack。请记住,一项重要技能是注意细节。如果查看“应该看到的内容”部分,则会看到我在命令行上运行带有参数的脚本。您应该复制我精确运行的方式。
确保运行命令:
$ python ex13.py first 2nd 3rd>> The script is called: ex13.py >> Your first variable is: first >> Your second variable is: 2nd >> Your third variable is: 3rd
您可以确保提供了参数。
if __name__ == '__main__': if len(argv) == 4: 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 else: print 'You forgot the args...'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)