返回信息流问题:“name 'Template' is not defined”
python的这个模板需要安装吗?怎么讲解中貌似是内置函数呢
这是一条镜像帖。来源:北邮人论坛 / python / #1526同步于 2014/7/7
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖
关于Template的问题
falldew
2014/7/7镜像同步13 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
【 在 falldew 的大作中提到: 】
: 问题:“name 'Template' is not defined”
: python的这个模板需要安装吗?怎么讲解中貌似是内置函数呢
django里面的?
我在GUI里输入 t = Template('Return the $item to $owner.')
直接报错了Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
t = Template('Return the $item to $owner.')
NameError: name 'Template' is not defined
本来程序是
>>> t = Template('Return the $item to $owner.')
>>> d = dict(item='unladen swallow')
>>> t.substitute(d)
将item字段换掉的。
这是需要安装django并调用其中的template吗
【 在 Chon 的大作中提到: 】
: 贴代码
: 没有上下文怎么回答
: 发自「贵邮」
【 在 falldew 的大作中提到: 】
: 感觉也是,但是报错了啊,找不到
django里的模板变量使用"{{}}"定义的,用$定义的应该是字符串模板变量。
你加一句import string试试?
不行,没用啊,和原来一样,我感觉好像要安装包的
【 在 HaSep 的大作中提到: 】
: django里的模板变量使用"{{}}"定义的,用$定义的应该是字符串模板变量。
: 你加一句import string试试?