有没有一种简单的方法可以在mako中调用给定字符串名称的函数?
You should be able to look it up in the dict returned by globals()
. Eg.:
<$ func_name = 'my_function_name' %>
${globals()[func_name](...)}
Although, this does smell rather nasty to me. If you could expand upon your end game perhaps we can figure out something a bit saner.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.