0
点赞
收藏
分享

微信扫一扫

python中的类和对象


1. 定义python中的类

python中的类和对象_深拷贝

在类之内定义的称为方法,在类之外定义的称为函数。

python中的类和对象_python_02

注意各个方法的使用:(有些需要带参数有些不需要带参数)

python中的类和对象_python_03

2. 对象的创建

python中的类和对象_pycharm_04

class Student:

native_place:'山西'

def __init__(self,name,age):
self.name=name
self.age=age



stu=Student('张三',20)
print(stu)
print(stu.name)
print(stu.age)

python中的类和对象_python_05

2.1 各种方法之间的调用

python中的类和对象_python_06

2.2 动态绑定属性和方法

python中的类和对象_浅拷贝_07

打开画图面板的指令是(mspaint)

python中的类和对象_深拷贝_08

3. 面向对象的三大特征

python中的类和对象_浅拷贝_09

3.1 封装的实现方式

python中的类和对象_python_10

python中的类和对象_浅拷贝_11

python中的类和对象_pycharm_12

3.2 继承的实现方式

python中的类和对象_pycharm_13

python中的类和对象_python_14

class Person():
def __init__(self,name,age):
self.name=name
self.age=age
def show(self):
print('姓名:{0},年龄:{1}'.format(self.name,self.age))

class Student(Person):
def __init__(self,name,age,score):
super().__init__(name,age)
self.score=score
stu=Student('王小懒',24,'80')

stu.show()

3.3 方法重写

python中的类和对象_深拷贝_15

3.4 多态的实现

python中的类和对象_深拷贝_16

4. 特殊属性和特殊方法

python中的类和对象_深拷贝_17

python中的类和对象_pycharm_18

5. 类的浅拷贝和深拷贝

python中的类和对象_pycharm_19

5.1 浅拷贝

python中的类和对象_深拷贝_20

5.2 深拷贝

python中的类和对象_pycharm_21

6. 模块的学习

6.1 创建和导入模块

python中的类和对象_浅拷贝_22

6.2 举例(数学模块math)

python中的类和对象_深拷贝_23

6.3 以主程序方式运行

python中的类和对象_深拷贝_24

python中的类和对象_python_25

python中的类和对象_python_26

7. python中的包

python中的类和对象_深拷贝_27

python中的类和对象_pycharm_28

7.1 python中常用的内置模块

python中的类和对象_python_29

7.2 第三方模块的安装与使用

python中的类和对象_深拷贝_30

7.3 定时发送某个文件的案例

import schedule
import time
def job():
print("一直哈哈大笑")

schedule.every(3).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)



举报

相关推荐

0 条评论