我正在尝试使用Python 3.6.通过新代码,我偶然发现了这个新语法:
f"My formatting string!"
Run Code Online (Sandbox Code Playgroud)
看来我们可以这样做:
>>> name = "George"
>>> print(f"My cool string is called {name}.")
My cool string is called George.
Run Code Online (Sandbox Code Playgroud)
任何人都可以对这个内部运作有所了解吗?特别是f前缀字符串可以采用的变量范围是多少?