AttributeError: 'tuple' object has no attribute 'size'
时间: 2023-09-27 12:09:04 浏览: 298
This error occurs when you are trying to access the 'size' attribute of a tuple object, but tuples do not have a 'size' attribute.
For example:
```
my_tuple = (1, 2, 3)
print(my_tuple.size)
```
In this code, we are trying to print the size of the tuple 'my_tuple', but since tuples do not have a 'size' attribute, we get the AttributeError.
To fix this error, you can use the built-in function 'len()' to get the length of a tuple:
```
my_tuple = (1, 2, 3)
print(len(my_tuple))
```
This will output the correct length of the tuple, which is 3 in this case.
阅读全文
相关推荐






