这是怎么回事 求解!
Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。
C:\Users\STXJY>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> def fn_get_grade(self):
... if self.score>=80:
... return 'a'
... if self.score>=60:
... return 'b'
... return 'c'
...
>>> class person(object):
... def __init__(self,name,score):
... self.name=name
... self.score=score
...
>>> p1=person('bob',90)
>>> p1.get_grade=types.MethodType(fn_get_grade,p1,person)
>>> print p1.get_grade
<bound method person.fn_get_grade of <__main__.person object at 0x02284250>>
>>>