AttributeError: 'numpy.int64' object has no attribute 'strip'
时间: 2023-09-25 12:06:07 浏览: 330
PyQt学习随笔:自定义信号连接时报AttributeError: ‘PyQt5.QtCore.pyqtSignal’ object has no attribute ‘connect’
5星 · 资源好评率100%
This error occurs when you try to use the `.strip()` method on a `numpy.int64` object. The `.strip()` method is used to remove whitespace from strings, but it cannot be used on integers.
To fix this error, you should check if the object you are trying to use `.strip()` on is a string or an integer. If it is an integer, you should convert it to a string first before using the `.strip()` method.
For example:
```
x = 123
if isinstance(x, int):
x = str(x)
x = x.strip()
```
This code checks if `x` is an integer, converts it to a string if it is, and then uses the `.strip()` method to remove any whitespace.
阅读全文