發(fā)送
import requests as r
res = r.post('http://localhost:8080/hello', json={
'name': '小明'
})
print(res.json()['name'])
接收
bottle是python的web框架,只需要引用一個(gè).py
文件即可,點(diǎn)擊去下載頁(yè)文章來源地址http://www.zghlxwxcb.cn/news/detail-608858.html
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)
文章來源:http://www.zghlxwxcb.cn/news/detail-608858.html
到了這里,關(guān)于python 發(fā)送和接收post請(qǐng)求的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!