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])