猫史档案馆


Python新版本上线

用户:爱玩电脑的源码风车爱玩电脑的源码风车查看: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


回复

上一页1 页 / 共 1下一页
爱玩电脑的源码风车爱玩电脑的源码风车

注意:如有单词或语句不理解,请联系作者翻译。

点赞0


评论


死神Basic死神Basic

链接:喵喵喵()

点赞0


评论


SCS_user_LoeheodVOQSCS_user_LoeheodVOQ

python310都有了,而且要下载也是在官网里下载方便,你发一段官方文档又不解释干啥()

点赞0


评论


oWuGi7s6oWuGi7s6

(python11.x都出了)

 

点赞0


评论


爱玩电脑的源码风车爱玩电脑的源码风车

如有问题,请联系作者:bcm_034@qq.com

点赞0


评论


一个哈密瓜一个哈密瓜

拜托,py3.11.x都出了,您搁这解释3.8.x??????

 

点赞0


评论


爱玩电脑的源码风车爱玩电脑的源码风车

链接请在手机上浏览。

点赞0


评论


mornwindmornwind

《Python 3.8 was released on October 14th, 2019.》

点赞0


评论