python-json



Python Json



import requests import json From pprint import pprint# beautification print Use of #json.dump # response = requests.get('https://m.douban.com/rexxar/api/v2/subject_collection/ # movie_showing/items?os=android&for_mobile=1&start=0&count=18&loc_id=108288&_=1501385491364') # response_dict = json.loads(response) # f = open('douban.txt','w') # ensure_ascii=False guarantees normal Chinese display, no acsii encoding # indent=2 Let the child content be two spaces above the parent content # json.dump(response_dict,f,ensure_ascii=False,indent=2) # f.close() # with open('douban1.txt','w')as f: # json.dump(response_dict,f,ensure_ascii=False,indent=2) # json.load use f = open('douban1.txt','r') ret = json.load(f) pprint(ret)