# coding=utf-8
import requests
import json
from pprint import pprint
url = "https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items?start=0&count=18"
r = requests.get(url)
json_response = r.content.decode()
#json字符串转化为字典
dict_response = json.loads(json_response)
# pprint(dict_response)
#把python类型转化为字符串?
#str
# json.dumps(dict_response)
with open("douban.json","w") as f:
f.write(json.dumps(dict_response,ensure_ascii=False,indent=2))
with open("douban.json","r") as f:
t = json.loads(f.read())
print(t)
import requests
import json
from pprint import pprint
url = "https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items?start=0&count=18"
r = requests.get(url)
json_response = r.content.decode()
#json字符串转化为字典
dict_response = json.loads(json_response)
# pprint(dict_response)
#把python类型转化为字符串?
#str
# json.dumps(dict_response)
with open("douban.json","w") as f:
f.write(json.dumps(dict_response,ensure_ascii=False,indent=2))
with open("douban.json","r") as f:
t = json.loads(f.read())
print(t)