2011年(264)
分类: Python/Ruby
2011-06-14 16:42:16
from django.template import Template, Context
p={}
p['a']='asdf'
p['b']='qwer'
p['c']='1234'
z={}
z={
'dict':p
}
c = Context(z)
方法一:
t = Template('{% for key, value in dict.items %}{{ key }}===>{{ value }}\n{% endfor %}')
t.render(c)
方法二:
t = Template('{% for key in dict.items %}{{ key.0 }}===>{{ key.1 }}\n{% endfor %}')
t.render(c)