Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }}.
您需要将
{{
和}}
加倍:以下是Python documentation for format string syntax的相关部分:
你可以通过加倍大括号来逃避它
例如:
Python 3.6+(2017)
在Python的最新版本中,可以使用f-strings(另请参见PEP498)
对于f字符串,应该使用双精度
{{
或}}
产生所需的结果
如果需要解析括号中的表达式而不是使用文本,则需要三组括号:
产生
相关问题 更多 >
编程相关推荐