import urllib
import json
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
RCMC_URL = ""
RCMS_URL_response = urllib.urlopen(RCMC_URL).read()
json_obj = json.loads(RCMS_URL_response)
list_rcms = []
for channels in json_obj:
CID = channels["channelCode"]
BU_name = channels["bu"]
list_rcms.append({"channel_id":CID,"BU":BU_name})
josn_rcms = json.dumps(list_rcms,ensure_ascii=False)
with open("rcms_channels.txt","w")as f:
f.write(josn_rcms)
红色标注的是需要添加的,例子中要输出的是json_rcms的结果,其中有中文字符;
阅读(5902) | 评论(0) | 转发(0) |