文章详情页
python3 通过bottle获取请求参数但中文是乱码
浏览:143日期: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. angular.js - ng-grid 和tabset一起用时,grid width默认特别小2. python for循环中的函数只能运行一次?3. android - 美团筛选处筛选条件停靠+条件点击滑动到顶部。4. javascript - Vue.js2.0不能使用debounce后大伙一般是如何解决延迟请求的问题的呢。5. python的文件读写问题?6. python - pyspider爬取了接近1G的数据,无法导出csv?7. css - transform-origin 旋转参考点8. 请问是对象还是数组9. html5 - 在一个页面中 初始了两个swiper 不知道哪里错了 一直不对10. html - 爬虫时出现“DNS lookup failed”,打开网页却没问题,这是什么情况?
排行榜
