我有一个字符串,我在其中使用字符串格式:
'SELECT {} FROM {} WHERE country={} AND \{\}'.format("apples", "tables","home")
目前这不起作用;如何转义{和}以便打印字符串:
SELECT apples FROM tables WHERE country=home AND {}
答案 0 :(得分:10)
您可以使用{}
{{}}
序列
>>> 'SELECT {} FROM {} WHERE country={} AND {{}}'.format("apples", "tables","home")
'SELECT apples FROM tables WHERE country=home AND {}'