第十四章 函数和方法的区别

函数和方法的区别

function —— A series of statements which returns some value to a caller. It can also be passed zero or more arguments which may be used in the execution of the body. 

method —— A function which is defined inside a class body. If called as an attribute of an instance of that class, the method will get the instance object as its first argument (which is usually called self)

函数 - 一系列向调用者返回一些值的语句。 它也可以传递零或多个可用于执行主体的参数。

方法 - 一个在类体内定义的函数。 如果作为该类的一个实例的属性被调用,该方法将获取实例对象作为其第一个参数(通常称为self)。


猜你喜欢

转载自blog.csdn.net/weixin_42473953/article/details/80755931