Python部落(python.freelycode.com)组织翻译,禁止转载,欢迎转发。
Py-backwards
Python到python的编译器允许你在老版本中使用Python 3.6的一些功能,你可以通过这个在线样例(https://py-backwards.herokuapp.com/)试用它。
需要Python 3.3 来运行,可以向下编译至Python 2.7。
支持的特性
目标 3.5:
格式化字符串常量:如 f"hi {x}" (https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatted-string-literals)
变量注释:如 x: int = 10 和 x: int (https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep526)
数字常量中的下划线:如 1_000_000(自动进行) (https://docs.python.org/3/whatsnew/3.6.html#pep-515-underscores-in-numeric-literals)
目标 3.4:
带星标的(元组)解包:如 [*range(1, 5), *range(10, 15)] 和 print(*[1, 2], 3, *[4, 5]) (https://docs.python.org/3/whatsnew/3.5.html#pep-448-additional-unpacking-generalizations)
字典解包:如 {1: 2, **{3: 4}} (https://docs.python.org/3/whatsnew/3.5.html#pep-448-additional-unpacking-generalizations)
目标 3.3:
目标 3.2:
目标 2.7:
|