我正在使用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()