![1cc2c9378831e950ae68ac227a6e56e6.png](https://i-blog.csdnimg.cn/blog_migrate/f71b9e921b11c51a7a1d2efa34505822.jpeg)
在使用Flask过程中,可能会遇到这样的情况:一篇Ariticle,对应数量不定的多个Tag,我们需要通过多个Tag找到相应文章,这时应该如何使用URL传参呢?
例如:
@app.route('/')
def hello():
tags = requests.args.getlist('tag')
print('tags')
我们使用requests.args.getlist()
方法获取相关参数。
在浏览器或Postman中测试:
http://host/tag=hello$tag=hi&tag=nihao
在Console中的返回值:
['hello', 'hi', 'nihao']
参考文献
List of query params with Flask request.argsstackoverflow.com![1d9a4dfd99fc482bb3fb882e6aee238d.png](https://i-blog.csdnimg.cn/blog_migrate/94829aac8700f00af4c8d8e19af4746c.png)
感谢关注、点赞、收藏。