这f-string是Python 3.6中的新功能之一.
但是,当我尝试这个:
>>> f"\{10}"
'\\{10'
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么左大括号'{'保留在结果中.我认为结果应该与str.format:
>>> "\{}".format(10)
'\\10'
Run Code Online (Sandbox Code Playgroud)
在PEP-0498中,它没有明确回答这个问题.那么是什么原因导致左大括号'{'留在结果和是什么原因导致之间的差异f-string和str.format()?