class Person:
name = None
age = None
def hello(self):
print("hello,python")
def hi():
print("hi,python")
p1 = Person()
p2 = Person()
p1.hi = hi
# p2.hi hi函数只添加到对象p1中,并非添加到Person类中
print(type(p1.hi),type(p1.hello))
# output:<class 'function'> <class 'method'>
python中可以使用函数给对象添加方法,但是仅仅添加在该对象中做函数使用,并非添加到类中作为成员方法使用。