文章详情页
python3 通过bottle获取请求参数但中文是乱码
问题描述
通过客户端请求服务器,有请求参数,如果请求参数带有中文则不能正确输出.代码如下
哪位大侠帮忙解决下?小弟不胜感激
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. javascript - 关于js,alert()阻塞的问题2. javascript - 函数声明和匿名函数有什么不同?(前端小白求助。。)3. HTML5禁止img预览该怎么解决?4. python - 请问这两个地方是为什么呢?5. javascript - 关于js原生事件的绑定与解除绑定6. dologin说是没有定义7. javascript - 手机点击input时,button会被顶上去?求解决!!!8. angular.js - 在ionic下,利用javascript导入百度地图,pc端可以显示,移动端无法显示9. mybatis - Java关于Mysql的随机id生成10. mysql - 数据库建字段,默认值空和empty string有什么区别 110
排行榜