Heim > Artikel > Backend-Entwicklung > Python 3.5 有什么新特性?
Python 3.5.0a3本回答至少在很多地方有错误 详情python 3.5 中 PEP0484 新加入的 Type Hints 的使用方法是什么? - 酿泉的回答Python 3.5.0a3 was released on March 30th, 2015.
Major new features of the 3.5 series, compared to 3.4Python 3.5 is still in development, and 3.5.0a1 is the second alpha release. Many new features are still being planned and written. Among the new major new features and changes in the 3.4 release series so far are
- PEP 461, adding support for "%-formatting" for bytes and bytearray objects
- PEP 465, a new operator (@) for matrix multiplication
- PEP 475, adding support for automatic retries of interrupted system calls
- PEP 471, os.scandir()
PEP 484, the typing module, a new standard for type annotations好爽,好爽,狂喜乱舞中!
<code class="language-python"><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">TypeVar</span><span class="p">,</span> <span class="n">Iterable</span><span class="p">,</span> <span class="n">Tuple</span>
<span class="n">T</span> <span class="o">=</span> <span class="n">TypeVar</span><span class="p">(</span><span class="s">'T'</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">complex</span><span class="p">)</span>
<span class="n">Vector</span> <span class="o">=</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Tuple</span><span class="p">[</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">]]</span>
<span class="k">def</span> <span class="nf">inproduct</span><span class="p">(</span><span class="n">v</span><span class="p">:</span> <span class="n">Vector</span><span class="p">)</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="k">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">v</span><span class="p">)</span>
</code>
Python 3.5将支持Async/Await异步编程