tweepy得到最后提及

时间:2018-06-26 11:35:34

标签: python-3.x tweepy

我要确保每次有人提到我(“ @name”)时,它都会在控制台中打印出一些内容,将其写入文件中,这样它就不会打印两次相同的内容,直到下一次提及出现。

功能在类中,如果有的话。 myMentions = tweepy.Cursor(api.mentions_timeline).items()

def check_if_won(self, myMentions):
    openfile = open('lastid.txt', 'r')
    readfromfile = openfile.read()
    for mention in myMentions:
        if str(mention.id) not in readfromfile:
            try:
                writetofile = open('lastid.txt', 'a')
                writetofile.write(str(mention.id))
                writetofile.close()
                print(mention.text)
                print("$$$$$$$$$$$$ JACKPOT $$$$$$$$$$$$")
                print('\n')

            except Exception:
                pass
        else:
            pass

我哪里出错了?

0 个答案:

没有答案