(第九篇)python中特殊的内置变量-魔法方法
摘要:一、__doc__ 用于获取对象的文档字符串,文档字符串用三重引号表示,可以在函数、类、模块等Python对象中使用,于描述该对象的用途、参数、返回值等信息。 def my_function(): """This is the docstring for my_function.""" pass p
阅读全文
python创建类的两种方式和类由自定义type创建
摘要:(1)第一种:直接创建 1 class Foo(object,metaclass=type): 2 def __init__(self): 3 print("我执行了") 4 super().__init__() 5 6 def test(self,x): 7 return x+1 (2)第二种:通
阅读全文