2007年12月06日 星期四 08:57
对于list可以用{% for a in list%} 来处理。那传入一个dict怎么得到key和对应的值呢?谢谢
--
wayne
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071206/d54927ec/attachment-0001.html
2007年12月06日 星期四 10:59
在 07-12-6,温铭<wenming在kingsoft.net> 写道: > 对于list可以用{% for a in list%} 来处理。那传入一个dict怎么得到key和对应的值呢?谢谢 > > -- > wayne > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > {% for key, value in dict.items %}{{ key }}{{ value }}{% endfor %} -- 想飞之心,永远不死! Registered Linux User 404987 [http://counter.li.org]
2007年12月06日 星期四 11:46
x.y¾Í¿ÉÒÔÁË Dots have a special meaning in template rendering. A dot in a variable name signifies *lookup*. Specifically, when the template system encounters a dot in a variable name, it tries the following lookups, in this order: - Dictionary lookup. Example: foo["bar"] - Attribute lookup. Example: foo.bar - Method call. Example: foo.bar() - List-index lookup. Example: foo[bar] On 12/6/07, wang bin <wangbin1979在gmail.com> wrote: > > ÔÚ 07-12-6£¬ÎÂÃú<wenming在kingsoft.net> дµÀ£º > > ¶ÔÓÚlist¿ÉÒÔÓÃ{% for a in list%} À´´¦Àí¡£ÄÇ´«ÈëÒ»¸ödictÔõôµÃµ½keyºÍ¶ÔÓ¦µÄֵĨ£¿Ð»Ð» > > > > -- > > wayne > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > {% for key, value in dict.items %}{{ key }}{{ value }}{% endfor %} > -- > Ïë·ÉÖ®ÐÄ£¬ÓÀÔ¶²»ËÀ£¡ > Registered Linux User 404987 [http://counter.li.org] > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071206/31a25b58/attachment.html
2007年12月06日 星期四 19:35
{% for entry in lst %}
{% endfor %}
On Dec 6, 2007 11:46 AM, @@ <askfor在gmail.com> wrote:
> x.y¾Í¿ÉÒÔÁË
>
>
> Dots have a special meaning in template rendering. A dot in a variable
> name signifies *lookup*. Specifically, when the template system encounters
> a dot in a variable name, it tries the following lookups, in this order:
>
> - Dictionary lookup. Example: foo["bar"]
> - Attribute lookup. Example: foo.bar
> - Method call. Example: foo.bar()
> - List-index lookup. Example: foo[bar]
>
>
>
>
> On 12/6/07, wang bin <wangbin1979在gmail.com> wrote:
> >
> > ÔÚ 07-12-6£¬ÎÂÃú<wenming在kingsoft.net> дµÀ£º
> > > ¶ÔÓÚlist¿ÉÒÔÓÃ{% for a in list%} À´´¦Àí¡£ÄÇ´«ÈëÒ»¸ödictÔõôµÃµ½keyºÍ¶ÔÓ¦µÄֵĨ£¿Ð»Ð»
> > >
> > > --
> > > wayne
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to
> > > python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info:
> > > http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> > {% for key, value in dict.items %}{{ key }}{{ value }}{% endfor %}
> > --
> > Ïë·ÉÖ®ÐÄ£¬ÓÀÔ¶²»ËÀ£¡
> > Registered Linux User 404987 [http://counter.li.org]
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071206/6bd62e8f/attachment.html
Zeuux © 2025
京ICP备05028076号