TypeError:无法连接“ str”和“ Redditor”对象

然后
Traceback (most recent call last):
  File "run.py", line 56, in <module>
    run(r, comments_replied_to)
  File "run.py", line 30, in run_bot
    b.write("Author=" + comment.submission.author + "\n")
TypeError: cannot concatenate 'str' and 'Redditor' objects

这是从代码中获得的回溯,我不确定如何解决此问题,谢谢。

这是代码

with open ("first.txt", "a") as f, open 
    ("second.txt", "a") as b:
        f.write(comment.id + "\n")
            b.write("author=" + comment.submission.author + "\n")

我猜您正在使用PRAW,并希望获得reddit用户名?现在,您正在尝试将字符串与Redditor对象连接在一起。

相反,您需要使用Redditor.name来访问用户名。看一下该Redditor对象的文档

在你的情况下

comment.submission.author.name

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TypeError:无法连接“ str”和“ UUID”对象

TypeError:无法连接“ str”和“ float”对象:pandas

Python:TypeError无法连接'str和'list'对象

Python Selenium TypeError:无法连接“ str”和“ WebElement”对象

TypeError:无法连接“ str”和“ pygame.Surface”对象

Python:TypeError:无法连接“ str”和“ int”对象

re.search()TypeError:无法连接“ str”和“ NoneType”对象

TypeError:无法连接'str'和'function'对象的python文件

Tkinter Label,TypeError:无法连接“ str”和“ instance”对象

abaqus脚本:TypeError:无法连接“ str”和“ Set”对象

Python TypeError:无法连接“ str”和“ list”对象

openerp无法连接“ str”和“ function”对象

TypeError:无法连接电子邮件中的“ str”和“ list”对象

TypeError:无法连接类型为“ <class'str'>”的对象;仅Series和DataFrame objs有效

Python TypeError:尝试打印时无法连接“ str”和“ int”对象

TypeError:无法连接'str'和'NoneType'对象python bs4

TypeError:无法使用MySQL连接Flask中的'str'和'float'对象

Python:TypeError:无法连接“str”和“int”

TypeError:无法连接“ str”

TypeError:将自定义网址放入scrapy.Request()时,无法连接“ str”和“ NoneType”对象

类型错误:无法连接“str”和“int”对象 1

rpsls游戏“(python)错误:无法连接'str'和'int'对象

类型错误无法连接“ str”和“ ErrorList”对象

无法连接'str'和'list'对象列表包含整数

如何连接str和int对象?

TypeError:无法连接类型为“<class 'str'>”的对象;只有 Series 和 DataFrame objs 有效我收到此错误

TypeError:无法将“ float”对象隐式转换为str或TypeError:-:“ str”和“ float”的不受支持的操作数类型

如何解决无法连接“ str”和“ file”对象的错误?

无法连接“ str”和“ int”对象,但可以通过自己的IDLE正常运行吗?