小编Tar*_*ara的帖子

python中的模板

如何编写一个函数render_user,它接受userlist返回的一个元组和一个字符串模板,并返回替换到模板中的数据,例如:

>>> tpl = "<a href='mailto:%s'>%s</a>"
>>> render_user(('matt.rez@where.com', 'matt rez', ), tpl)
"<a href='mailto:matt.rez@where.com>Matt rez</a>"
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激

python string format templates

7
推荐指数
1
解决办法
4022
查看次数

标签 统计

format ×1

python ×1

string ×1

templates ×1