ValueError: not enough values to unpack (expected 4, got 1)(ValueError:没有足够的值来解包(预期 4,得到 1))
问题描述
错误出现在 script, first, second, third = argv
.我想了解我收到错误的原因以及如何解决它.
The error is at script, first, second, third = argv
. I would like to understand why I am getting the error and how to fix it.
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)
推荐答案
argv
变量包含命令行参数.在您的代码中,您期望 4 个参数,但只有 1 个(第一个参数始终是脚本名称).您可以在 pycharm
中配置参数.转到 Run
-> Edit Configurations
.然后创建一个新的python配置.您可以在那里指定 Script parameters
字段.或者您可以按照 dnit13 的说明从命令行运行脚本.
argv
variable contains command line arguments. In your code you expected 4 arguments, but got only 1 (first argument always script name). You could configure arguments in pycharm
. Go to Run
-> Edit Configurations
. Then create a new python configuration. And there you could specify Script parameters
field. Or you could run your script from command line as mentioned by dnit13.
这篇关于ValueError:没有足够的值来解包(预期 4,得到 1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ValueError:没有足够的值来解包(预期 4,得到 1)


- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01