python/ string/ templates

I'd like to template out some config files, but they are not compatible with python's "this is a {template}".format(template='string') formatting

eg. curly braces are part of the config (nginx config).

Can you change the delimiters to something else?

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

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

暂无
暂无

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.

Related Question How to split string in python using multiple delimeters python split string on multiple delimeters without regex Appending various strings between two delimeters in one string. python Python: How to split string containing extra delimeters as value string split on multiple delimeters Python: how to change a Multipolygon in string format to list function to get rid of delimeters in python Change string format into date time format or separate them via Python? Python - split string with multiple delimeters, return dictionary delimeter as key remaining item as value Removing hyperlinks from a string without removing delimeters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM