简体   繁体   English

为什么不从__future__中以Python <3.6导入formatted_string_literals?

[英]Why no from __future__ import formatted_string_literals in Python <3.6?

We had from __future__ import print_function in 2.7, so could we have from __future__ import formatted_string_literals in, say, 3.4 and 3.5 (maybe even 2.7)? 我们from __future__ import print_function 2.7中的from __future__ import print_function ,所以可以from __future__ import formatted_string_literals 3.4和3.5中的from __future__ import formatted_string_literals (甚至是2.7)吗?

Is there some policy that prohibits this, some technical reason, or just nobody got around tuit yet? 是否有一些禁止这种情况的政策,某些技术原因,或者还没有人绕过学步呢?

Ref: PEP 498: Formatted string literals 参考: PEP 498:格式化的字符串文字

from __future__导入中的f字符串是用来引入不兼容的更改的,f字符串是一项新功能,而不是重大更改。

Bringing f-strings to Python less than 3.6 is now covered at https://stackoverflow.com/a/46182112/8508004 . https://stackoverflow.com/a/46182112/8508004讨论了将f字符串带到Python不到3.6的问题。 It is done via future-fstrings and simply requires a special line at the top of your code. 这是通过future-fstrings完成的 ,只需要在代码的顶部添加特殊行即可。

(I wanted to comment above but couldn't yet due to reputation restrictions for that.) (我想在上面发表评论,但由于声誉限制而无法发表。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM