`

python 学习之调用web api

阅读更多
import urllib
import json
url = 'http://xxx.xxx.xxx.xxx:8888/xxxx-api/customer/qq/channels'
def get_data():
    response = urllib.urlopen(url).read()
    json_array = json.loads(response)
    channel = {}
    for json_map in json_array:
        channel[json_map['code']] = json_map['name']
    return channel;
if __name__ == '__main__':
    clist = get_data()
    for key in clist.keys():
        print("%s %s") % (key, clist[key])
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics