文章详情页
python3 通过bottle获取请求参数但中文是乱码
浏览:215日期:2022-09-18 18:19:22
问题描述
通过客户端请求服务器,有请求参数,如果请求参数带有中文则不能正确输出.代码如下
哪位大侠帮忙解决下?小弟不胜感激
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:
换成这个方法即可:request.query.(请求参数字典的key值)
request.query.message
相关文章:
1. python - pip install出现下面图中的报错 什么原因?2. python - 怎样在linux下开发flask web应用时查看代码出错(traceback)的地方。3. python3.x - python多进程,不能在同一窗口吗4. mysql - 数据库字段命名问题,新人,求解5. python - nginx为什么不能反代图片?6. css - input中transition 设置background-color过渡,chrome浏览器页面初始化渲染会有过度效果7. Browser-sync安装失败问题8. windows-7 - Win7中Vmware Workstatoin与Xampp中Apache服务器端口冲突?9. 微信端电子书翻页效果10. html5 - api.douban.com/v2/movie/in_theaters?start=0&count=3 不在以下合法域名列表中
排行榜

网公网安备