DNB*_*ims 6 string escaping string-formatting python-3.x
这是字符串:
'''This is a test { <-- escape these ---> } '''
Run Code Online (Sandbox Code Playgroud)
我想逃避
{
和
}
在格式化方法中,我该怎么办?谢谢.
如果您需要在文字文本中包含大括号字符,可以通过加倍{{和}}来对其进行转义.
试试这个:
'''This is a test {{ <-- escape these ---> }} and the value is {0}'''.format(42)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1521 次 |
| 最近记录: |