Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法将“int”对象转换为str_Python_Python 3.x - Fatal编程技术网

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获取帮助^?