Python -IndentationError:意外的缩进(使Reddit Bot产生)[重复]

问题描述 投票:-3回答:1

IndentationError: unexpected unindent为什么?这是我的代码:

from praw.models import MoreComments
import praw
import giris
import time
import os

def bot_login():
    print("Loggin in...")
    r = praw.Reddit(username = giris.username,
            password = giris.password,
            client_id = giris.client_id,
            client_secret = giris.client_secret,
            user_agent = "karton_bardak_bot")
    print("Logged in!")
    return r

info="""
\n
\n
\n
^(ben bot) \n
\n
^(bruh)
"""

subreddit=r.subreddit("shithikayeler")

def run_bot(r, comments_replied_to):
    print("Obtaining 25 comments...")
    for submission in subreddit.new():
        toReply=True
        for top_level_comment in submission.comments:
            if isinstance(top_level_comment, MoreComments):
                continue
            if not submission.is_self:
                toReply=False
            if top_level_comment.author=="karton_bardak_bot" or submission.selftext=='':
                toReply=False
                print("PASSED "+ submission.url)
                log.write("PASSED "+ submission.url+"\n")
        if toReply:
            try:
                new=reply(submission.selftext, info)
                submission.reply(new)

            except Exception as e:
                log.write("ERROR: " + str(e) + "   on submission " + submission.url)
            print("REPLIED "+ submission.url)
            log.write("REPLIED "+submission.url+"\n")
            try:
                time.sleep(60)   

r = bot_login

while True:
    run_bot(r)

它说:

 File "bot.py", line 57
    r = bot_login
    ^
IndentationError: unexpected unindent

为什么?我已经检查了数千次,但找不到问题。请帮助。

python indentation
1个回答
0
投票
try:

没有提供所需的内容的块

except:

part ...

© www.soinside.com 2019 - 2024. All rights reserved.