我在Spyder中运行以下代码。
我将它输入到一个py文件中,然后简单地点击了运行按钮。
当我尝试运行时,出现了错误:
ValueError:需要多于1个值才能拆包
如此处所示,你应该在运行程序之前提供argv变量的输入,但我不知道如何在Spyder中实现这一点?
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 "Your third variable is:", third
argv
,看起来它是一个标量而不是元组。在调用脚本时,你的命令行参数是什么?你运行了python ex13.py first 2nd 3rd
吗?确保提供参数。 - Mr. Polywhirl