浅谈函数与方法的区别
其他模块使用我们定义好的类
.
├── __pycache__
│ └── c1.cpython-38.pyc
├── c1.py
└── c2.py
c1.py
class Person():
name = 'Scott'
age = '18'
address = '北京王府井大街'
def print_info(self):
print("name:"+self.name+", age:"+str(self.age)+", address:"+self.address)
c2.py
from c1 import Person
p = Person()
p.print_info()
name:Scott, age:18, address:北京王府井大街
- 方法: 设计层面
- 函数:程序运行、过程式的一种称谓