too many values to unpack
时间: 2023-09-26 12:06:22 浏览: 56
This error occurs when the number of variables on the left side of an assignment statement does not match the number of values on the right side. For example:
a, b = 1, 2, 3
In this code, we are trying to assign three values to only two variables. To fix this error, we need to either add another variable or remove one of the values:
a, b, c = 1, 2, 3
or
a, b = 1, 2
Another common cause of this error is when we try to unpack a sequence that has too many or too few elements. For example:
a, b = (1, 2, 3)
In this code, we are trying to unpack a tuple with three elements into two variables. To fix this error, we need to make sure that the sequence has the correct number of elements:
a, b, c = (1, 2, 3)
or
a, b = (1, 2)
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)