如何解决我使用的关于</body>的语法错误web.py?

2024-04-24 14:47:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在关注the tutorial on the web.py website,我试图让html页面正常工作,但我一直遇到这个错误:

<type 'exceptions.SyntaxError'> at /
invalid syntax Template traceback:
File 'templates\\index.html', line 14 </body> (index.html, line 14)

我不知道我做错了什么(因为我基本上只是复制/粘贴教程)。在

这里的内容索引.html:

^{pr2}$

以下是代码.py

import web

render = web.template.render('templates/')

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        name = 'Bob'
        return render.index(name)

if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

为什么它说</body>处有语法错误?结构与web.py?在


Tags: thenamepywebappindexonhtml
1条回答
网友
1楼 · 发布于 2024-04-24 14:47:01

不要在模板中使用html、head和body标记。 所以你的代码应该是这样的:

$def with (name)

$if name:
    I just wanted to say <em>hello</em> to $name.
$else:
    <em>Hello</em>, world!

相关问题 更多 >