标签:div pre http none hid imm 方法参数 imp closed
1.Flask-----get
@app.route(‘/get‘,methods=["get"]) def get(): print(f"request.args{request.args}") return ‘GET!‘
2.Flask-----post
@app.route(‘/post‘,methods=["post"]) def post(): print(f"request.form{request.form}") print(f"request.get_data{request.get_data()}") print(f"request.get_json{request.get_json()}") print(f"request.files{request.files}") return ‘POST!‘
3.爬虫之get方法参数详解
import requests,json url_get = "http://127.0.0.1:5000/get" pm = {"name":"my name is Get"} res = requests.get(url_get,params=pm) print(res.text) ‘‘‘ 1.params = 字典 request.argsImmutableMultiDict([(‘name‘, ‘my name is Get‘)]) ‘‘‘
4.爬虫之post方法参数详解
import requests,json url_post = "http://127.0.0.1:5000/post" data_data = {"name":"my name is POST_data"} data_json = {"name":"my name is POST_json"} res = requests.post(url_post,data=json.dumps(data_data),json=data_json) print(res.text) """ 有data,那么json就不生效 1.json=data_json request.get_data b‘{"name": "my name is POST_json"}‘ request.get_json {‘name‘: ‘my name is POST_json‘} 2.json=json.dumps(data_json) request.get_datab‘"{\\"name\\": \\"my name is POST_json\\"}"‘ request.get_json{"name": "my name is POST_json"} 3.data=data_data request.form ImmutableMultiDict([(‘name‘, ‘my name is POST_data‘)]) 4.data=json.dumps(data_data) request.get_data b‘{"name": "my name is POST_data"}‘ """
Flask获取post,get参数,以及 爬虫 requests的get,post参数详解
标签:div pre http none hid imm 方法参数 imp closed
原文地址:https://www.cnblogs.com/3-wusen/p/14976099.html