您的位置:首页技术文章
文章详情页

python3 通过bottle获取请求参数但中文是乱码

【字号: 日期:2022-09-18 18:19:22浏览:55作者:猪猪

问题描述

通过客户端请求服务器,有请求参数,如果请求参数带有中文则不能正确输出.代码如下

哪位大侠帮忙解决下?小弟不胜感激

from bottle import route, run, template, request@route(’/’, method=’GET’)def do_json(): str = ’your request msg is %s %s %s’ % (request.params[’message’], request.params[’age’], request.params[’sex’]) print(str) return {’respon’:str}run(host=’localhost’,port=8080, debug=True,reloader=True)

结果是如下的乱码:your request msg is adam 18 妖怪

问题解答

回答1:

python3 通过bottle获取请求参数但中文是乱码

换成这个方法即可:request.query.(请求参数字典的key值)

request.query.message

标签: Python 编程
相关文章: