小册名称:Python合辑5-格式化字符串
如果想打印由大括号括起来的变量名称,而不是该变量的值,那就需要双层大括号 {{}}。
>>> hello = "world">>>f"{{hello}} = {hello}"'{hello} = world'
>>> hello = "world"
>>>f"{{hello}} = {hello}"
'{hello} = world'
而如果想转义双引号,就需要在引号前用反斜线 \ 做标记。
>>>f"{hello} = \"hello\""'world = "hello"'
>>>f"{hello} = \"hello\""
'world = "hello"'