【发布时间】:2016-06-15 04:16:03
【问题描述】:
我正在试用 Python 3.6。在浏览新代码时,我偶然发现了这种新语法:
f"My formatting string!"
看来我们可以这样做:
>>> name = "George"
>>> print(f"My cool string is called {name}.")
My cool string is called George.
任何人都可以阐明其内部工作原理吗?特别是 f 前缀字符串可以采用的变量范围是什么?
【问题讨论】:
标签: python scope string-formatting python-3.6 f-string