Python 3.5 有什麼新功能¶
- 編輯者:
Elvis Pranskevichus <elvis@magic.io>, Yury Selivanov <yury@magic.io>
本文介紹了 Python 3.5 與 3.4 相比多了哪些新功能。Python 3.1 已於 2015 年 9 月 13 日發布。完整詳情請見 changelog。
也參考
PEP 478 - Python 3.5 發佈時程
發布重點摘要¶
新增語法特性:
PEP 492,使用 async 和 await 語法的協程
PEP 465, a new matrix multiplication operator:
a @ b.PEP 448, additional unpacking generalizations.
新的函式庫模組:
新的內建功能
bytes % args,bytearray % args: PEP 461 -- Adding%formatting to bytes and bytearray.New
bytes.hex(),bytearray.hex()andmemoryview.hex()methods. (Contributed by Arnon Yaari in bpo-9951.)memoryviewnow supports tuple indexing (including multi-dimensional). (Contributed by Antoine Pitrou in bpo-23632.)Generators have a new
gi_yieldfromattribute, which returns the object being iterated byyield fromexpressions. (Contributed by Benno Leslie and Yury Selivanov in bpo-24450.)A new
RecursionErrorexception is now raised when maximum recursion depth is reached. (Contributed by Georg Brandl in bpo-19235.)
CPython 實作改進:
When the
LC_TYPElocale is the POSIX locale (Clocale),sys.stdinandsys.stdoutnow use thesurrogateescapeerror handler, instead of thestricterror handler. (Contributed by Victor Stinner in