1. Template對象構造
Template對象有7種構造方法, 分別如下:
- * 直接使用字符串
t = Template("The king is a $placeholder1.")
Pass the template definition as a string.
- * 使用模板文件
t = Template(file="fink.tmpl")
Read the template definition from a file named "fink.tmpl".
- *使用文件對象
t = Template(file=f)
Read the template definition from file-like object 'f'.
- *重載方法,加入填入信息
t = Template("The king is a $placeholder1.", searchList=[dict, obj])
t = Template(file="fink.txt", searchList=[dict, obj])
t = Template(file=f, searchList=[dict, obj])
posted on 2008-06-25 17:45
JustRun 閱讀(333)
評論(0) 編輯 收藏 所屬分類:
Cheetah