这个错误提示说明在一个整数类型的对象上调用了'endswith()'方法,但是整数类型没有'endswith()'方法。

解决方法是将整数类型转换成字符串类型,再调用'endswith()'方法。例如:

number = 12345
string = str(number)
if string.endswith('5'):
    print('The number ends with 5')
else:
    print('The number does not end with 5')
Python 错误:'int' object has no attribute 'endswith' 解决方法

原文地址: https://www.cveoy.top/t/topic/oG6J 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录