如何在Flask上获取查询字符串? [英] How do you get a query string on Flask?

查看:242
本文介绍了如何在Flask上获取查询字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何获取查询字符串的瓶子文档不明显。我是新的,看着文档,找不到!

所以

  @ app.route('/')
@ app.route('/ data')
def data():
query_string = ??????
return render_template(data.html)


解决方案

<



$> b
$> b $ b $这里我们要的是获得用户的价值(即?用户=一些价值)
user = request.args.get('user')


Not obvious from the flask documention on how to get the query string. I am new, looked at the docs, could not find!

So

@app.route('/')
@app.route('/data')
def data():
    query_string=??????
    return render_template("data.html")

解决方案

from flask import request

@app.route('/data')
def data():
    # here we want to get the value of user (i.e. ?user=some-value)
    user = request.args.get('user')

这篇关于如何在Flask上获取查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆