pathlib.Path前往布尔结果相似办法 exists(),is_dir(), is_file(),is_mount(), is_symlink(),is_block_device(), is_char_device(),is_fifo(), is_socket()如今回到False而不是提高 ValueError或它的子类UnicodeEncodeError的包含字符的不可表示在操作系统级别途径。(由Serhiy Storchaka供稿于bpo-33721。)
shutilshutil.copytree()如今接受一个新的dirs_exist_ok关键字参数。
SSL添加SSLContext.post_handshake_auth以启用和 ssl.SSLSocket.verify_client_post_handshake()启动TLS 1.3握手后身份验证。
统计添加statistics.fmean()为更快的浮点变体statistics.mean()。
添加statistics.multimode()了前往最常见值的列表。
添加statistics.NormalDist了一个用于创立和操作随机变量的正态散布的工具.
1>>>
2>>> temperature_feb = NormalDist.from_samples([4, 12, -3, 2, 7, 14])
3>>> temperature_feb
4NormalDist(mu=6.0, sigma=6.356099432828281)
5
6>>> temperature_feb.cdf(3) # Chance of being under 3 degrees
70.3184678262814532
8>>> # Relative chance of being 7 degrees versus 10 degrees
9>>> temperature_feb.pdf(7) / temperature_feb.pdf(10)
101.2039930378537762
11
12>>> el_nino = NormalDist(4, 2.5)
13>>> temperature_feb += el_nino # Add in a climate effect
14>>> temperature_feb
15NormalDist(mu=10.0, sigma=6.830080526611674)
16
17>>> temperature_feb * (9/5) + 32 # Convert to Fahrenheit
18NormalDist(mu=50.0, sigma=12.294144947901014)
19>>> temperature_feb.samples(3) # Generate random samples
20[7.672102882379219, 12.000027119750287, 4.647488369766392]
tar文件该tarfile模块如今默以为新档案的现代pax(POSIX.1-2001)格式,而不是之前的GNU特定格式。这经过标准化和可扩展格式的分歧编码(UTF-8)提高了跨平台的可移植性,并提供了其他一些益处。
令牌化当提供没有尾随新行的输入时,tokenize模块如今隐式地收回NEWLINE令牌。此行为如今与C tokenizer在外部执行的操作相婚配。
Tkinter添加的办法selection_from(), selection_present(), selection_range()和 selection_to() 在tkinter.Spinbox类。
moveto() 在tkinter.Canvas课堂上添加了办法。
时间CLOCK_UPTIME_RAW为macOS 10.12 添加了新时钟。
unicodedata新函数is_normalized()可用于验证字符串能否处于特定的正常方式。
单元测试添加addModuleCleanup()并 addClassCleanup()停止unittest以支持setUpModule()和的 清算setUpClass()。
VENVvenv如今,Activate.ps1在PowerShell Core 6.1下,一切平台上都包含一个用于激活虚拟环境的脚本。
XML作为对DTD和外部实体检索的缓解,默许状况下, xml.dom.minidom和xml.sax模块不再处置外部实体。
优化
subprocess如今,模块可以os.posix_spawn()在某些状况下运用该功用以取得更好的功用。目前,假设满足一切这些条件,它仅用于macOS和Linux
(责任编辑:admin)