【发布时间】:2017-04-21 11:34:30
【问题描述】:
#!/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? -
好的,我来分享完整代码
-
import simplejson as json
标签: python python-3.5