2013-05-08 21 views
2

我想模板了一些配置文件,但它們與Python的 "this is a {template}".format(template='string')格式化更改字符串格式定界符在python

如兼容。大括號是config(nginx config)的一部分。

你可以改變分隔符到別的東西嗎?

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

+0

AFAIK,這不是不可能覆蓋format()方法。 – 2013-05-08 05:59:15

+1

**另請參閱:** https://stackoverflow.com/questions/35574349/python-format-string-with-custom-delimiters – dreftymac 2017-10-29 09:32:19

回答