#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import json as simplejson
#write tweet objects to JSON
file = open('tweet.json', 'wb')
print ("Writing tweet objects to JSON please wait...")
for status in alltweets:
json.dump(status._json,file,sort_keys = True,indent = 4)
#close the file
print ("Done")
file.close()
if __name__ == '__main__':
#pass in the username of the account you want to download
get_all_tweets("@AlertZaAfrica")
Python编译器指出第54行有错误。我已经将import json定义为simplejson。上面的区域展示了我定义import json的位置。
import simplejson as json
吗?既然你已经使用 Python 3.5,为什么不直接写成import json
呢? - Jon Clementsimport simplejson as json
- ferdy