标签:转换 __name__ odi def print 方法 requests json port
# -*- coding: utf-8 -*- import requests import xmltodict import json def get_response(request_url): r = requests.get(request_url) rt = r.text return rt def xmlstr2jsonstr(xmlstr): xmlparse = xmltodict.parse(xmlstr)
#dumps()方法的ident=1,格式化json jsonstr = json.dumps(xmlparse,indent=1) return jsonstr def main(request_url): xmlstr = get_response(request_url) jsonstr = xmlstr2jsonstr(xmlstr) print(jsonstr) if __name__ == ‘__main__‘: request_url = ‘‘ main(request_url)
标签:转换 __name__ odi def print 方法 requests json port
原文地址:https://www.cnblogs.com/navysummer/p/10062461.html