如何在 mako 中执行此操作:
<% import cherrypy %>
...
<link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" />
AttributeError: 'Undefined' object has no attribute 'url'
最佳答案
答案:而不是 <% import cherrypy %>
一个需要<%! import cherrypy %>
关于python - 在mako模板: call python function within html string中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4007898/