2024-06-26 02:09:22 发布
网友
我使用字符串模板,例如:
from string import Template s = Template(u'(True, $type)') res = s.substitute(type={'type': bool}) print res
输出:
(True, {'type': <type 'bool'>})
但是,我需要:
(True, {'type': bool})
我该怎么做?你知道吗
试试这个:
>>> res = s.substitute(type="{'type': bool}") >>> res u"(True, {'type': bool})"
试试这个:
相关问题 更多 >
编程相关推荐