class Person():
def __call__(self, name): # 带有两条线的是类的内置函数
print("__call__" + name)
def hello(self,name):
print("hello" + name)
"""
调用类的内置函数和自定义函数的区别
"""
person = Person()
person('zkl') # 调用内置函数不需要.函数名
person.hello('zkl') # 调用类的自定义函数需要.函数名
pytorch入门1:调用类的内置函数和自定义函数的区别
最新推荐文章于 2022-06-23 18:47:48 发布