![](/img/trans.png)
[英]MissingSectionHeaderError: File contains no section headers.(configparser)
[英]configparser.MissingSectionHeaderError: File contains no section headers. Reddit bot
我正在制作一個 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 bot 教程,但我不知道它為什么不起作用。 我的 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'
別擔心,這些不是我的真實信息,用戶名是第二個帳戶,不是我的主要帳戶。
好的,想通了,只需將 [DEFAULT] 放在 praw.ini 的頂部
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.