简体   繁体   English

如何使用Mako登录?

[英]How to use log in Mako?

How do I take the 'log' of a particular variable "testvar" in a Mako template? 如何在Mako模板中获取特定变量“ testvar”的“日志”? Assume that testvar is already a number. 假设testvar已经是一个数字。 It does not appear clear in the documentation as to how one would do this. 关于如何执行此操作,在文档中似乎还不清楚。

You can import math inside the template, then call math.log : 您可以将math导入模板中,然后调用math.log

>>> from mako.template import Template
>>> print Template("<%import math%>${math.log(testvar)}").render(testvar=2)
0.69314718056

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM