1)flask
会自动设置Content-Type:
1.标准写法
@app.route("/")
def index():
dic = {"name":"wang"}
rsp = make_response(jsonify(dic))# 会自动设置Content-Type: application/json
return rsp
2.简单写法
@app.route("/")
def index():
dic = {"name":"wang"}
return jsonify(dic) # 会自动设置Content-Type: application/json
2)requests
import requests
r = requests.get('https://api.github.com/events')
r.json()
# json.load(r.text) # 和上面的等价
# json.load(r.content.decode('utf-8') # 和上面的等价
3)前端
没有响应操作,直接查看