【问题标题】:configparser.MissingSectionHeaderError: File contains no section headers. Reddit botconfigparser.MissingSectionHeaderError:文件不包含节标题。 Reddit 机器人
【发布时间】:2020-07-12 08:01:26
【问题描述】:

我正在制作一个 reddit 机器人。但是当我尝试运行它时,我得到了错误

configparser.MissingSectionHeaderError: File contains no section headers.

我已将 praw.ini 文件放入 $HOME/.config,正如文档所述。我的文件如下所示:

 #!/usr/bin/python
import praw

reddit = praw.Reddit('bot1')

subreddit = reddit.subreddit("learnpython")

for submission in subreddit.hot(limit=5):
    print("Title: ", submission.title)
    print("Text: ", submission.selftext)
    print("Score: ", submission.score)
    print("---------------------------------\n")

我正在关注 learnpython 的 reddit 机器人教程,但我不知道为什么它不起作用。我的 praw.ini 文件在这里:

submission_kind=t3
subreddit_kind=t5
oauth_url=https://oauth.reddit.com
reddit_url=https://www.reddit.com
short_url=https://redd.it
[bot1]
client_id='ryg5shdn6Hbs'
client_secret= 'ePLMUKgMuh5GBbs58jdlsu52'
password='Icethebear10'
username='attherealicebear'
user_agent='omegapybot 0.1'

别担心,这些不是我的真实详细信息,用户名是第二个帐户,而不是我的主要帐户。

【问题讨论】:

    标签: python bots


    【解决方案1】:

    好吧,想通了,只需将 [DEFAULT] 放在 praw.ini 的顶部

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 2019-06-07
      • 2017-02-11
      • 2022-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-07
      相关资源
      最近更新 更多