Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获取 Mako 模板中特定变量“testvar”的“日志”?假设 testvar 已经是一个数字。文档中似乎并不清楚如何做到这一点。
math您可以在模板中导入,然后调用math.log:
math
math.log
>>> from mako.template import Template >>> print Template("<%import math%>${math.log(testvar)}").render(testvar=2) 0.69314718056