擅长:python、mysql、java
<p>你可能在找<code>operator.methodcaller</code>。你知道吗</p>
<p>例如:</p>
<pre><code>import operator
sorted(TheGame.turn, key=operator.methodcaller('distance_to_goal', TheGame.hole.goal_position))
</code></pre>
<p><a href="https://docs.python.org/2/library/operator.html#operator.methodcaller" rel="nofollow">https://docs.python.org/2/library/operator.html#operator.methodcaller</a></p>