cannot unpack non-iterable int object
时间: 2024-01-17 12:08:09 浏览: 27
This error occurs when you try to unpack a non-iterable integer object. In Python, unpacking is the process of assigning values from an iterable to multiple variables at once. For example:
a, b = [1, 2]
Here, the values 1 and 2 are unpacked from the list [1, 2] and assigned to the variables a and b.
However, if you try to unpack a non-iterable integer object, such as:
a, b = 1
You will get the "cannot unpack non-iterable int object" error. This is because an integer object is not iterable, meaning it cannot be broken down into smaller parts that can be assigned to multiple variables.
To fix this error, make sure you are unpacking an iterable object, such as a list or tuple. If you want to assign a single integer value to multiple variables, you can do so using multiple assignment:
a = b = 1
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)