not enough values to unpack (expected 3, got 1)
时间: 2023-09-04 17:07:56 浏览: 88
关于 Python opencv 使用中的 ValueError: too many values to unpack
This error message typically occurs when you are trying to unpack values from an iterable, but the number of values you are trying to unpack does not match the number of items in the iterable.
For example, let's say you have the following code:
```python
a, b, c = [1]
```
Here, you are trying to unpack three values from a list that only contains one item. Python will raise a "not enough values to unpack" error, because you are trying to unpack more values than there are items in the iterable.
To fix this error, you need to make sure that the number of values you are trying to unpack matches the number of items in the iterable. For example, you could modify the above code to:
```python
a, b, c = [1, 2, 3]
```
Here, you are unpacking three values from a list that contains three items, so Python will not raise an error.
阅读全文