Python中文
首页
教程
问答
标签
搜索
登录
注册
jsonunicode转换为字符串,这样我就可以在Django html pag中使用它
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p><strong>编辑:</strong></p> <p>有人告诉我如何解码unicode,我只想把jsonunicode打印到我开发的html页面中。我从<a href="https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB0QFjAA&url=https%3A%2F%2Fapify.heroku.com%2Fresources%2F4fda2ede485abc0001000034&ei=ytu8U9qqFYqwuASj_ICoDA&usg=AFQjCNFA44iaXXsuzNX9RrchrnryRRkLRA&bvm=bv.70138588,d.c2E" rel="nofollow">heroku api</a>获得api。在</p> <p>我几乎每一步都很正确。但是输出是unicode的,我不知道如何提取内容并显示到页面中。在</p> <p>我需要打印内容。怎么做?在</p> <p>我的视图.py在</p> <pre><code>template_vars['kural'] = json.dumps(thirukural[x]) t = loader.get_template('index.html') c = Context(template_vars) #pprint.pprint(c) return HttpResponse(t.render(c)) </code></pre> <p>Html页面</p> ^{pr2}$ <p>它现在是这样印刷的</p> <pre><code>யாதனின் யாதனின் நீங்கியான் நோதல் அதனின் அதனின் இலன். </code></pre> <p>但是在heroku api页面中,示例输出如下所示</p> <pre><code> { "id": "213", "kural": "புத்தே ளுலகத்தும் ஈண்டும் பெறலரிதே\n\nஒப்புரவின் நல்ல பிற." } </code></pre> <p>您可以看到我的输出没有<code>line breaks that \n</code>。我怎么能做到呢?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p><code>kural</code>变量是dict,如果要在视图中显示<code>kural</code>,我认为您需要json。在</p> <pre><code>import json template_vars['kural'] = json.dumps(thirukural[x]) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在乒乓球比赛中预测球的轨迹,对于AI球拍预测?
3 回答
如何在乒乓球游戏中阻止球
3 回答
如何在乘法和模中不乘空间?
8 回答
如何在乘法和除以2个不同的数字之间进行交换?
9 回答
如何在也是数据一部分的单个字符上拆分大字符串
6 回答
如何在乾草堆中找到針,有更好的解決方案嗎?
9 回答
如何在事件wxWidgets中传递自定义数据
9 回答
如何在事件中使用lambda i=i?
6 回答
如何在事件中心只接收最近的数据
7 回答
如何在事件发生之前保持云函数运行?
8 回答
如何在事件发生后使页面重定向到同一页面
1 回答
如何在事件回调之间保持python生成器的状态
4 回答
如何在事件处理程序(pythonsocket、sphinx)中保留docstring
5 回答
如何在事件处理程序中更改wxRichTextCtrl的光标位置?
10 回答
如何在事件处理程序中访问外部对象?
1 回答
如何在事件循环中将协程打包为正常函数?
3 回答
如何在事件循环之外运行协同程序?
8 回答
如何在事件循环结束时为并发未来的所有线程调用类方法?
1 回答
如何在事件文件中只保留一份摘要?
4 回答
如何在事件模板中添加事件
7 回答