我收到了一个python笔记本,其中充满了像f"{expr=}"
这样的表达式,它们在我的环境中会产生错误消息:
var=7
print(f"{var=}")
File "<fstring>", line 1
(var=)
^
SyntaxError: invalid syntax
我怀疑/期望它实际上可能是f"expr={expr}"
的一种新语法,即如下print语句:
print(f"var={var}")
var=7
事实上,我经常使用类似于后者的表达式来进行调试,如果能有一个简写就好了
这是比我的python(3.7.6)更高的版本吗?或者它是fstring
模块的定制?
在web或SE上搜索它并没有什么效果
如果它不是一个标准功能,我如何才能让它工作
Answer - Python Version 3.8
Read more here
这个特性在Python issue 36817中讨论过,并在Python 3.8中发布
相关问题 更多 >
编程相关推荐