龟叔推荐!Python3.10再更新版本,全新七大特点
来源:
奇酷教育 发表于:
龟叔推荐!Python3 10再更新版本,全新七大特点!
“
Python3.10再更新版本,全新七大特点!龟叔推荐!

01
Python3.10 alpha版本安装
对于从事数据科学和人工智能领域的人们来说,Python 是大家的首选编程语言。
根据最近的一项调查,27% 的程序员开发职位要求掌握 Python 语言,今年年初这一数字还只是 18.5%。
Python 流行的原因在于其拥有非常直观的能力:这门语言拥有大量的库、足够高的生产效率,还相对易于学习。
Python3.10 alpha版本的安装,这里我们以Windows平台进行展示。
大家首先进入到Python的官网来下载Python的安装包,官网的地址为:
https://www.Python.org/downloads/windows/

上图中有两个可以下载的版本,分别是zip压缩包和exe可执行文件。
对于zip压缩包,大家下载后,直接解压即可使用,而exe文件则需要大家点击运行,进行Python3.10环境的安装,安装完成后,点击Python.exe得到下图结果,表明我们已经成功安装。

02
新特性介绍
对于Python3.10版本,有许多新的特性:
· 类型检查改进
· 类型别名更改
· 频率统计
· 丢弃了Distutils库
· 字典增加了mapping属性
· 函数zip()增加了新参数
· 模版匹配(类似c++ switch/case)
03
全新七大特点
对于Python3.10版本,有许多新的特性:
(1)类型检查改进

Python3.10版本中,联合运算符使用“|”线来代替了旧版本中的Union[]方法,使得程序更加简洁。

(2)类型别名的更改

Python3.10版本中,则通过TypeAlias来规定了类型名字的替换。
(3)二进制表示中的频率为1的数量统计

在Python3.10版本中,可以通过调用bit_count函数来统计二进制中数字“1”的个数。
(4)准备弃用Distutils 内置库

由于Distutils库的功能已经被此setuptools和package库取代了,所以本着简洁性的原则,Distutils在不久的将来将会被完全的删除掉。
(5)字典增加mapping属性

在Python3.10中,针对于字典的三个方法,items,keys和values都增加了一个新的“mapping”属性,通过上述的程序可以发现,对三个方法调用mapping属性后都会返回原字典数据。
(6) zip() 增加 strict 参数

Python3.10中对于zip函数添加了strict参数。
(7)模板匹配

Python 3.10 引入了结构化的模式匹配,通过match...case关键词来完成,可以匹配字典,类以及其他更复杂的结构。