小编rab*_*010的帖子

Python 3.5.1:NameError:未定义名称'json'

#!/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")
Run Code Online (Sandbox Code Playgroud)

python编译器说第54行是错误的.我已经将import json定义为simplejson.上面我定义了导入json的区域如上所示.

python python-3.5

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

python-3.5 ×1