我最近开始学习python,我正在玩tweepy。现在我有点搞不清这段代码是做什么的,尤其是类部分,以及传递给类的是什么。你知道吗
对python类和对象做了一些研究,但仍然没有得到多少成果。你知道吗
class PrintListener(tweepy.StreamListener):
def on_data(self, data):
tweet = json.loads(data)
print('@%s: %s' % (tweet['user']['screen_name'], tweet['text'].encode('ascii', 'ignore')))
def on_error(self, status):
print(status)
从Tweepy website:
因此基本上,一旦成功,
on_data
方法将以JSON文件的形式接收消息,并打印tweet以及关于作者的信息。你知道吗相关问题 更多 >
编程相关推荐