webpy 如何返回中文?
时间:2011-10-20
来源:互联网
服务器端用的是webpy,因为用了 ajax,所以服务器返回时直接 “return 结果”, 但是因为搞不清楚python的编码,无论怎么,服务器都返回 '\xe6\x95\xb0\xe6\x8d\xae\xe5\xba' 这样的字符串,请问如何返回中文字符串?
作者: zhangweiwindow 发布时间: 2011-10-20
补充一下。以下是代码:
Python code
在倒数第二行中,用print在控制台中输入是中文,但是 return 后就成了楼上所说的内容了。
各位路过大侠请伸出援手。
Python code
def GET(self): ''' 从数据库中获取权限内容并添加到web页面的选择列表中 ''' operations = self.db.connection.select('sys_operation_dim') if mode == "RIA": result = { "total":"", "lines" : [] } total = 0 web.header("Content-Type","text/plain; charset=utf-8") for operation in operations: total += 1 result["lines"].append({"index":str(total), "operationCode": operation['operation_code'], "operationName":operation['operation_name']}) result["total"] = str(total) print result["lines"][0]["operationName"] return result
在倒数第二行中,用print在控制台中输入是中文,但是 return 后就成了楼上所说的内容了。
各位路过大侠请伸出援手。
作者: zhangweiwindow 发布时间: 2011-10-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28