tweets = []
save_file = open('9may.json', 'a')


class CustomStreamListener(tweepy.StreamListener):

    def __init__(self, api):
        self.api = api
super(tweepy.StreamListener, self).__init__()
self.save_file = tweets

def on_data(self, tweet):
    self.save_file.append(json.loads(tweet))
print(tweet)
save_file.write(str(tweet))
How do I save streaming tweets in json via tweepy?