Python 无法将“int”对象转换为str
我有以下导致以下错误的代码Python 无法将“int”对象转换为str,python,python-3.x,Python,Python 3.x,我有以下导致以下错误的代码 elif args[0]=="online": onlines = zxLoLBoT.get_friends_online(self) self.message(sender, "Toplam "+len(onlines)+" kişi açık.") 您试图将字符串与整数连接起来 内置函数将始终返回整数类型,因此在将其连接到另一个字符串时,必须将其转换为字符串 len(...) len(object) Return the num
elif args[0]=="online":
onlines = zxLoLBoT.get_friends_online(self)
self.message(sender, "Toplam "+len(onlines)+" kişi açık.")
您试图将字符串与整数连接起来
内置函数将始终返回整数类型,因此在将其连接到另一个字符串时,必须将其转换为字符串
len(...)
len(object)
Return the number of items of a sequence or collection.
您试图将字符串与整数连接起来
内置函数将始终返回整数类型,因此在将其连接到另一个字符串时,必须将其转换为字符串
len(...)
len(object)
Return the number of items of a sequence or collection.
我通常会这样做:
self.message(sender, "Toplam {} kişi açık.".format(len(onlines)))
这样,您就不需要使用额外的代码来将int转换为str。我将使用以下方法:
self.message(sender, "Toplam {} kişi açık.".format(len(onlines)))
这样,您就不需要使用额外的代码将int转换为str。oow yis:D:D我使用lenstronlines XD thx获取帮助^oow yis:D:D我使用lenstronlines XD thx获取帮助^?