Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PRAW Reddit。引发错误:AttributeError:';列表';对象没有属性';格式';_Python_Python 3.x_Python Requests_Reddit_Praw - Fatal编程技术网

Python PRAW Reddit。引发错误:AttributeError:';列表';对象没有属性';格式';

Python PRAW Reddit。引发错误:AttributeError:';列表';对象没有属性';格式';,python,python-3.x,python-requests,reddit,praw,Python,Python 3.x,Python Requests,Reddit,Praw,因此,程序在没有错误的情况下至少运行了30次这部分代码,我以前也运行过多次程序,但从未出现过这个错误 可能是什么问题 我最近添加了一部分代码,其中如果“if keyword['keyword']=='testing something':”那么它将执行“checkkw=checkkw.splitlines()”而不是“checkkw=checkkw.split()”,这是我所做的唯一更改,并且出现了这个错误,但是,我不确定这个更改是如何导致错误的 for submission in search

因此,程序在没有错误的情况下至少运行了30次这部分代码,我以前也运行过多次程序,但从未出现过这个错误

可能是什么问题

我最近添加了一部分代码,其中如果“if keyword['keyword']=='testing something':”那么它将执行“checkkw=checkkw.splitlines()”而不是“checkkw=checkkw.split()”,这是我所做的唯一更改,并且出现了这个错误,但是,我不确定这个更改是如何导致错误的

for submission in search_reddit:
                print(submission.title, submission.id)


                ###creating dict
                topics_dict = { "title":[], \
                "score":[], \
                "id":[], "url":[], \
                "comms_num": [], \
                "created": [], \
                "body":[]}
                ### finish dict

                ### insert to dict
                topics_dict["title"].append(submission.title)
                topics_dict["score"].append(submission.score)
                topics_dict["id"].append(submission.id)
                topics_dict["url"].append(submission.url)
                topics_dict["comms_num"].append(submission.num_comments)
                topics_dict["created"].append(submission.created)
                topics_dict["body"].append(submission.selftext)
                ### finish inserting to dict
                if keyword['keyword'] == 'testing something':
                    checkkw = keyword['checkkw']
                    print(checkkw)
                    checkkw = checkkw.splitlines()
                    print(checkkw)
                    total = len(checkkw)
                else:
                    checkkw = keyword['checkkw']
                    checkkw = checkkw.split()
                    total = len(checkkw)

                [elem.lower() for elem in checkkw]
                [elem.lower() for elem in topics_dict['body']]

                print(total)
                print(checkkw)

                exists = 0
                if all(item in " ".join(topics_dict["body"]) for item in checkkw):
                    print('posting')
                    link = topics_dict['url'][0]
                    print(link)
                    result = self.dblinks.get(Query()['link'] == link)
                    if result is not None:
                        print('already posted to this link')
                    else:
                        try:
                            reply_template = keyword['comment']
                            reply_text = reply_template.format(topics_dict["url"])
                            submission.reply(reply_text)
                            self.dblinks.insert({'link': link})
                            time.sleep(1)
                        except Forbidden:
                            print('Error')
    ```