【发布时间】:2012-08-15 02:04:47
【问题描述】:
只是想知道龙卷风模板中变量的范围是什么。我在模板中有这段代码,但它失败了!
{% set dictionary = {'a' : 1, ... more letters here ... 'z' : 26} %}
{% set sum = 0 %}
{% for y in x %}
{% sum += int(dictionary[y.lower()]) #x is a string, y a char %}
{% end %}
{{ sum }}
但我明白了:
ParseError: unknown operator: 'sum'
发生了什么事?
【问题讨论】:
标签: python html templates tornado