我试图为我的测试subreddit编写一个机器人,但在我开始运行之前,我正在测试PRAW中的提交方法。要提交文本帖子,请使用以下行:
r.submit('Subreddit', 'Post Tile', text='Body')
但是如果你不想要一个身体呢?我在shell中写了这一行,但只要我用'Body'
或None
替换''
,我就会得到这个我不理解的长错误。< / p>
The PRAW documentation says text=None
被接受,但如果是这样,为什么我会收到错误?
我得到的错误是:
r.submit(&#39; Spedwards&#39;,&#39; Test&#39;,text = None)
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
r.submit('Spedwards', 'Test', text=None)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 338, in wrapped
return function(cls, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 237, in wrapped
return function(obj, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\__init__.py", line 2200, in submit
raise TypeError('One (and only one) of text or url is required!')
TypeError: One (and only one) of text or url is required!
subreddit.submit(&#39; Test&#39;,text = None)
Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
subreddit.submit('Test', text=None)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 59, in wrapped
return function(self.reddit_session, self, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 338, in wrapped
return function(cls, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\decorators.py", line 237, in wrapped
return function(obj, *args, **kwargs)
File "C:\Python34\lib\site-packages\praw\__init__.py", line 2200, in submit
raise TypeError('One (and only one) of text or url is required!')
TypeError: One (and only one) of text or url is required!
答案 0 :(得分:1)
文本的默认值为None。如果您不想包含任何文本,请设置text =''。您发布的是一个实际的错误,并且praw的主分支现在已经修复了该错误。