python的方法 是什么?与函数有什么区别?

最近在使用headfirstpython一书,书中一个语法也没讲,刚刚学了c语言,所以我不是很清楚方法和函数的区别

主要是在面向对象的思想中,有差别:
函数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).
从定义的角度上看,我们知道函数(function)就相当于一个数学公式,它理论上不与其它东西关系,它只需要相关的参数就可以。所以普通的在module中定义的称谓函数是很有道理的。
那么方法的意思就很明确了,它是与某个对象相互关联的,也就是说它的实现与某个对象有关联关系。这就是方法。虽然它的定义方式和函数是一样的。也就是说,在Class定义的函数就是方法。

方法和函数其实是一样的,只是不同语言的不同表述形式。一般来说,面向过程的语言会使用“函数”来描述,面向对象的语言会用“方法”来描述。

方法是有调用对象的。。。。。

通俗理解,方法就是函数,函数就是方法。但是,在面向对象语言里,方法才是真名。

方法就是函数,,一样的,,不同的说法而已

 方法是设计层面的概念,函数是实现层面的概念。
比如在java中,属性(字段)、方法都是用函数实现的:
class Person
{
    private String name;
        public void setName(String n) { name = n; }
        public String getName { return nane; }
        public void SayHello() { System.out.println("hello"); }
}
在设计层面看,Name是属性,SayHello是方法
在语言层面看 getName serName SayHello都是函数