擅长:python、mysql、java
<p>那么,你的意思是<code>obj.mymethod</code>是一个方法(隐式传递了<code>self</code>),而{<cd3>}是一个函数吗?在</p>
<p>基本上,<code>Klass.__dict__['mymethod']</code>是“raw”函数,它可以由一个叫做<em>描述符</em>的东西转换成一个方法。这意味着类上的每个函数都可以是普通函数和方法,这取决于您如何访问它们。这就是类系统在Python中的工作方式,非常正常。在</p>
<p>如果您想要方法,就不能通过<code>__dict__</code>(无论如何,您永远不应该这样做)。要获得所有方法,您应该执行<code>inspect.getmembers(Klass_or_Instance, inspect.ismethod)</code></p>
<p>您可以阅读<a href="http://docs.python.org/reference/datamodel.html" rel="nofollow noreferrer">details here</a>,关于这一点的解释在“用户定义方法”下。在</p>