TypeError: 'int' object is not subscriptable
时间: 2023-09-29 11:10:11 浏览: 54
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘tuple’
5星 · 资源好评率100%
This error occurs when you try to access an index or slice of an integer value, which is not possible as integers are not iterable.
For example:
```
num = 123
print(num[0])
```
This code will produce the error message "TypeError: 'int' object is not subscriptable" because we are trying to access the first index of the integer value "123", which is not possible.
To fix this error, you need to make sure you are applying index or slice operations only on iterable data types like lists, tuples, or strings.
阅读全文