我正在通过《学习Python The Hard Way 第三版》这本书来练习Python。我搜索到这本书是一个很好的入门资源。
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)
我收到一条错误消息,指出值错误:没有足够的值来解包(预期为 4 个,实际为 1)
。
最佳答案
您需要使用三个参数运行脚本,以便 argv
包含四个元素(第一个是脚本的名称)。
关于python - 这里有什么问题吗? Python2->Python3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45741563/