【问题标题】:Change string format delimeters in python在python中更改字符串格式分隔符
【发布时间】:2013-05-02 06:21:52
【问题描述】:

我想模板化一些配置文件,但它们与 python 的不兼容 "this is a {template}".format(template='string') 格式化

例如。花括号是配置(nginx 配置)的一部分。

你能把分隔符改成别的吗?

例如,'this is a [template]'.format(template='string')

【问题讨论】:

标签: python string templates


【解决方案1】:

解决方法是使用string.Template,记得转义所有$http://docs.python.org/2/library/string.html#template-strings

【讨论】:

    猜你喜欢
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    相关资源
    最近更新 更多