ITPub博客

首页 > 应用开发 > Python > Python3.9正式版本发布了

Python3.9正式版本发布了

原创 Python 作者:bgfbfvd 时间:2020-10-28 09:47:58 0 删除 编辑


Python 发布了版本号为 3.9.0的正式版,该版本包含了一些令人兴奋的新特性,作为爱学习的好同学还不来看看?


接下来带着大家了解一下这些特性以及它们的用法。


新的语法特性:


PEP 584, 新增字典合并运算


PEP 585, 标准集合中的类型提示


PEP 614, 放宽对装饰器的语法限制


新的内置特性:


PEP 616, 字符串新增移除前缀和后缀的方法


标准库的新特性:


PEP 593, 灵活的函数和变量注释;


os.pidfd_open() 允许在没有竞争和信号时的过程管理


Python 解释器改进:


PEP 573, 通过C扩展类型的方法快速访问模块状态


PEP 617, CPython现在使用基于PEG的新解析器一些 Python 内置的语法 (range, tuple, set, frozenset, list, dict) 通过 PEP 590 vectorcall 加速;


垃圾回收机制不会限制 resurrected objects。


现在,许多Python模块(_abc, audioop, _bz2, _codecs, _contextvars, _crypt, _functools, _json, _locale, math, operator, resource, time, _weakref)都使用 PEP 489 定义的多阶段初始化;


现在,许多标准库模块(audioop,ast,grp,_hashlib,pwd,_posixsubprocess,random,select,struct,termios,zlib)都使用PEP 384定义的稳定 ABI。


新的库模块:


PEP 615, IANA时区数据库现在位于 zoneinfo 模块的标准库中新的 graphlib 模块中提供了图的拓扑排序的实现。Python 3.9 是提供 python2 兼容层的版本,这能给python开发者更多时间移除python2支持和支持python3.9。例如,collections 模块中 抽象基类 的别名,例如 collections.abc.Mapping 的别名 collections.Mapping 会为向下兼容最后保留一个发行版。它们将在 Python 3.10 中被移除。


我们试试新的,首先安装下python3.9吧


新的特性


1.字典合并与更新运算符合并 (|) 和 更新 (|=) 运算符已经添加到字典里了,这些补充了现有的 dict.update 和 {** d1,** d2} 合并字典的方法。


示例:


>>> x={"key1":"value1 from x","key2":"value2 from x"}


>>> y={"key2":"value2 from y","key3":"value3 from y"}


>>> x | y{'key1':'value1 from x','key2':'value2 from y','key3':'value3 from y'}


>>> y | x{'key2':'value2 from x','key3':'value3 from y','key1':'value1 from x'}```


2.字符串的去除前缀/后缀的方法


增加了 str.removeprefix(prefix) 和 str.removesuffix(suffix) 用于方便地从字符串移除不需要的前缀或后缀。也增加了 bytes, bytearray 以及 collections.UserString 的对应方法。请参阅 PEP 616 了解详情。(由 Dennis Sweeney 在 bpo-39939 中贡献。)


3.类型的标注在类型标注中现在你可以使用内置多项集类型例如 list 和 dict 作为通用类型而不必从 typing 导入对应的大写形式类型名 (例如 List 和 Dict)。标准库中的其他一些类型现在同样也是通用的,例如 queue.Queue。


示例:


def greet_all(names: list[str])->None:


for name in names:


print("Hello", name)


4.New ParserPython 


3.9 使用于基于 PEG 的新解析器替代 LL(1)。新解析器的性能与旧解析器大致相当,但 PEG 在设计新语言特性时的形式化比 LL(1) 更灵活。我们将在 Python 3.10 及之后版本中开始使用这种灵活性。ast 模块会使用新解析器并会生成与旧解析器一致的 AST。在 Python 3.10 中,旧解析器将被移除,依赖于它的所有功能也将被移除(主要是 parser 模块,它早已被弃用)。只有 在 Python 3.9 中,你可以使用命令行开关 (-X oldparser) 或环境变量 (PYTHONOLDPARSER=1) 切换回 LL(1) 百家号的编辑器应该是我用过最难用的编辑器之一了,电脑打不开,手机端屎一样的体验

<a href="http://55589.darmg.com/">有没有上海本地的交友</a>

<a href="http://44085.darmg.com/">淮南本地交友微信群</a>

<a href="http://35004.darmg.com/">深圳本地交友群</a>

<a href="http://26880.darmg.com/">聊天交友网1100</a>

<a href="http://73620.darmg.com/">微博本地交友</a>

<a href="http://74390.darmg.com/">昆明本地交友群</a>

<a href="http://59602.darmg.com/">真有交友网</a>

<a href="http://61005.darmg.com/">重庆本地的交友软件</a>

<a href="http://99444.darmg.com/">广安本地寻亲交友</a>

<a href="http://03030.darmg.com/">泸州本地交友</a>

<a href="http://93664.darmg.com/">白山交友</a>

<a href="http://77373.darmg.com/">本地交友哪个软件好</a>

<a href="http://36338.darmg.com/">深圳交友网</a>

<a href="http://09343.darmg.com/">辉县本地离婚交友</a>

<a href="http://51422.darmg.com/">定西同城交友网</a>

<a href="http://88919.darmg.com/">威海本地交友群</a>

<a href="http://26645.darmg.com/">揭阳本地约会交友</a>

<a href="http://06713.darmg.com/">网上最大交友网</a>

<a href="http://56284.darmg.com/">无锡交友</a>

<a href="http://84329.darmg.com/">昆山交友</a>

<a href="http://90532.darmg.com/">丹东免费交友网</a>

<a href="http://44939.darmg.com/">51交友中心登录</a>

<a href="http://19630.darmg.com/">瑞安知已交友网</a>

<a href="http://57343.darmg.com/">交友征婚广州本地阿姨</a>

<a href="http://00259.darmg.com/">70后拉拉交友网</a>

<a href="http://27102.darmg.com/">无锡本地交友群</a>

<a href="http://83501.darmg.com/">沈阳**交友网</a>

<a href="http://68990.darmg.com/">佳缘登陆页面,世纪佳缘交友网</a>

<a href="http://06609.darmg.com/">有什么本地交友软件哪个好</a>

<a href="http://90826.darmg.com/">北京同城交友</a>

<a href="http://12559.darmg.com/">本地交友机构</a>

<a href="http://73194.darmg.com/">同志交友网站</a>

<a href="http://83449.darmg.com/">宜宾交友</a>

<a href="http://93633.darmg.com/">同城**网</a>

<a href="http://84804.darmg.com/">上饶本地未婚交友微信群</a>

<a href="http://66076.darmg.com/">平阴交友</a>

<a href="http://49324.darmg.com/">武汉本地交友论坛</a>

<a href="http://61792.darmg.com/">不收费同城交友网</a>

<a href="http://33278.darmg.com/">夜色交友网</a>

<a href="http://40022.darmg.com/">本地同城交友约会</a>

<a href="http://35816.darmg.com/">红叶国内交友网</a>

<a href="http://58087.darmg.com/">找一番交友网</a>

<a href="http://23795.darmg.com/">中年交友</a>

<a href="http://18854.darmg.com/">时尚交友</a>

<a href="http://40115.darmg.com/">本地交友的电话号码</a>

<a href="http://06118.darmg.com/">苏州本地交友网</a>

<a href="http://71336.darmg.com/">阳高交友网</a>

<a href="http://27210.darmg.com/">本地交友网站创新</a>

<a href="http://38978.darmg.com/">太原交友</a>

<a href="http://65808.darmg.com/">千百度交友网</a>

<a href="http://06798.darmg.com/">上海同城交友</a>

<a href="http://38464.darmg.com/">本地交友嫩江单身交友群</a>

<a href="http://94630.darmg.com/">深圳本地交友群</a>

<a href="http://53445.darmg.com/">武汉本地交友论坛</a>

<a href="http://22421.darmg.com/">下载本地交友</a>

<a href="http://02168.darmg.com/">淮南本地交友微信群</a>

<a href="http://92821.darmg.com/">变装交友</a>

<a href="http://95134.darmg.com/">简简单单交友网</a>

<a href="http://19617.darmg.com/">日照佳缘交友网</a>

<a href="http://80638.darmg.com/">江西交友网</a>

<a href="http://93590.darmg.com/">本地单身男女在线相亲交友</a>

<a href="http://72732.darmg.com/">大连本地交友相亲群</a>

<a href="http://96088.darmg.com/">杭州本地癖好交友约会</a>

<a href="http://91505.darmg.com/">石狮本地人交友群</a>


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69986038/viewspace-2730448/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2020-10-23

  • 博文量
    1
  • 访问量
    533