python json unicode - 如何使用 javascript 进行评估
确实花了很多时间寻找这个。请需要一些帮助。
我正在尝试向我的网络应用程序框架添加多语言功能。为此,我无法将非 ascii 字符作为 JSON 发送。这是我正在做的
这是我从数据库中获取的内容
'\xe0\xa4\xa4\xe0\xa5\x87\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4'
当我打印时,我可以得到哪个
तेस्त
我制作响应对象
response = {'a':'\xe0\xa4\xa4\xe0\xa5\x87\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4'}
发送响应
导入json
sys.stdout.write(json.dumps(response))
这就是它打印的内容
Returns u'{"a": "\u0924\u0947\u0938\u094d\u0924"}'
任何帮助,欢迎指点,
谢谢!
鲁沙布
Really spent a lot of time searching for this. Please need some help.
I am trying to add multilingual feature to my web app framework. For this I am unable to send non ascii characters as JSON. Here is what I am doing
Here is what I get from the database
'\xe0\xa4\xa4\xe0\xa5\x87\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4'
which when I print gives me which is okay
तेस्त
I make the response object
response = {'a':'\xe0\xa4\xa4\xe0\xa5\x87\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4'}
Send the repsonse
import json
sys.stdout.write(json.dumps(response))
This is what it prints
Returns u'{"a": "\u0924\u0947\u0938\u094d\u0924"}'
Any help, pointers will be welcome
Thanks!
Rushabh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您想要的输出吗(请参阅 < 的
ensure_ascii
参数代码>json.dumps)?Is this your desired output (see
ensure_ascii
argument forjson.dumps
)?