【发布时间】:2014-12-06 20:19:18
【问题描述】:
目的是从字典中提取数据,并以表格的形式返回键值对 这是我的 Python 代码部分:
dictionary = dict()
dictionary = {'hello': 1, 'hi': 2, 'go': 3}
output = template('make_table', wordList=dictionary)
return output
这是我的 make_table.tpl 文件的一部分:
<table>
%for index in wordList:
<tr>
<td>{{index}} </td>
</tr>
%end
</table>
不幸的是,tpl 文件只显示键:“hello”、“hi”和“go”,但没有显示它们的值。
我想要的是能够显示:
你好 1 嗨 2 去 3
谁能告诉我如何在 tpl 文件中索引值?
【问题讨论】:
标签: python dictionary html-table bottle