擅长:python、mysql、java
<p>详细说明见<a href="http://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods" rel="noreferrer">this article</a>。</p>
<p><strong>TL;DR</strong></p>
<p>1.它消除了<code>self</code>参数的使用。</p>
<p>2.它减少了内存使用,因为Python不必为每个对象实例化<a href="https://stackoverflow.com/questions/114214/class-method-differences-in-python-bound-unbound-and-static">bound-method</a>:</p>
<pre><code>>>>RandomClass().regular_method is RandomClass().regular_method
False
>>>RandomClass().static_method is RandomClass().static_method
True
>>>RandomClass.static_method is RandomClass().static_method
True
</code></pre>
<p>3.它提高了代码的可读性,表示该方法不依赖于对象本身的状态。</p>
<p>4.它允许方法重写,因为如果方法是在模块级(即类之外)定义的,则子类将无法重写该方法。</p>