Python子类回调中的计数器

时间:2016-08-12 22:15:22

标签: python

我正在使用TwythonStream Calss并且我正在尝试计算发现部分刺痛的实例的数量。下面的代码运行,但每个实例的计数器保持为1。作为Python NOOB的任何帮助或指针表示赞赏

from twython import TwythonStreamer

class myStream(TwythonStreamer):

    def on_success(self, data):

        if 'text' in data:
            counter = counter + 1
            print("found %d" % counter)
        if counter == 3:
            print("Found three!")
            self.disconnect()

0 个答案:

没有答案