扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

Python构造函数有哪些

扬州沐宇科技
2021-02-20 18:21:33
python, 构造函数

Python构造函数有哪些

Python中的构造函数是__init__函数

Python中子类如果定义了构造函数,父类的构造函数是不会执行的。

__init__函数使用方法:

class A:

def __init__(self, name):

self.name = name

class B(A):

def __init__(self, age):

self.age = age

扫码添加客服微信