python中的特殊方法使用
1 __doc__方法是python内置方法之一,该方法通常会输入指定对象中的注释部分
class ClassName:
'''
这个是我定义的类的注释
'''
def __init__(self):
'''
这是一个类属性
'''
index = ClassName()
print(index.__doc__) # print(index.__doc__)
print(index.__init__.__doc__) # 这是一个类属性
2 python中__module__模块用法详解
class Test(object):
def __init__(self):
self.name = "I'm test!"
from test import Test
from test import Test
u = Test()
print(u.name)
print(u.__module__) # u是来自哪个模块
print(u.__class__) # u是由哪个类产生