python 类
代码
class MyClass:
def __init__(self,name):
self.name = name
def print_name(self):
print("Hello", self.name)
m_class = MyClass("Python")
m_class.print_name()
输出:
Hello Python
其他
m_class = MyClass("Python")
实际上就是等于
m_class = object.__new__(MyClass)
MyClass.__init__(m_class,"Python")