用户:
爱玩电脑的源码风车查看:2 回复:8 评论:2 创建时间:2023-03-11T12:05:35
前几天作者发现了一个新版本的Python安装文件,这个版本号是3.8的,可能一般的训练师都不知道这个版本的新功能有哪些,现在本人就告诉你们
(这个版本支持的位数不仅支持喵位,也支持32位。)
Editor: Raymond Hettinger
This article explains the new features in Python 3.8, compared to 3.7. For full details, see the changelog.
Python 3.8 was released on October 14th, 2019.
Summary – Release highlights New Features Assignment expressions
There is new syntax := that assigns values to variables as part of a larger expression. It is affectionately known as “the walrus operator” due to its resemblance to the eyes and tusks of a walrus.
In this example, the assignment expression helps avoid calling len() twice:
if (n := len(a)) > 10:
print(f"List is too long ({n} elements, expected <= 10)")
A similar benefit arises during regular expression matching where match objects are needed twice, once to test whether a match occurred and another to extract a subgroup:
discount = 0.0
if (mo := re.search(r'(\d+)% discount', advertisement)):
discount = float(mo.group(1)) / 100.0
The operator is also useful with while-loops that compute a value to test loop termination and then need that same value again in the body of the loop:
# Loop over fixed length blocks
while (block := f.read(256)) != '':
process(block)
......
还有很多,请在Python的帮助文档中揭晓。
想安装和体验?请看链接。
链接:https://pan.喵/s/1fgRusyxstynqQk6uFV121A?pwd=5edu
提取码:5edu