python 发送和接收post请求

发送

import requests as r

res = r.post('http://localhost:8080/hello', json={
    'name': '小明'
})
print(res.json()['name'])

接收

bottle是python的web框架,只需要引用一个.py文件即可,点击去下载页

from bottle import route, run, request


@route('/hello',method='POST')
def hello():
    print(request.json['name'])
    return {'name':'小泓'}


run(host='localhost', port=8080,reloader=True)

你可能感兴趣的:(实践,python,json,开发语言)