2
内蟒功能如何做到这一点的灰鲭:在鲭模板:调用HTML字符串
<% import cherrypy %>
...
<link rel="stylesheet" href="${cherrypy.url('/media/layout.css')}" type="text/css" />
AttributeError: 'Undefined' object has no attribute 'url'
内蟒功能如何做到这一点的灰鲭:在鲭模板:调用HTML字符串
<% 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 %>
您是否尝试过引进别的东西,如数学? >>> t =模板('<%import math%>结果:$ {math.sqrt(9)}') >>> t.render() '结果:3.0' – atomocopter 2010-10-24 11:26:11
我明白了:您需要'<%! ... %>' – tauran 2010-10-24 11:41:20
@atomocopter如果你把这个解决方案写成一个正确的答案,那么tauran可以接受它,并且以后的用户不需要通过评论来寻找解决方案(并且你在这个过程中获得了一些东西);) – 2010-10-24 11:52:13