以下是字符串:
'''This is a test { <-- escape these ---> } '''
我想在format方法中转义
{
和
}
,我该如何做?谢谢。
以下是字符串:
'''This is a test { <-- escape these ---> } '''
{
和
}
,我该如何做?谢谢。
如果需要在文本中包含花括号,可以通过加倍来转义:{{和}}。
试一试:
'''This is a test {{ <-- escape these ---> }} and the value is {0}'''.format(42)