adict['mykey']ta có thể viết
adict.mykey
Trích tài liệu của Jinja:
You can use a dot (.
) to access attributes of a variable in addition to the standard Python__getitem__
“subscript” syntax ([]
).
The following lines do the same thing:
{{ foo.bar }}
{{ foo['bar'] }}
This is important if an object has an item and attribute with the same name. Additionally, theHếtattr()
filter only looks up attributes.
HVN at FAMILUG dot ORG
No comments:
Post a Comment