位置:- 正文

python __init__()的使用注意(python里面init)

编辑:rootadmin

推荐整理分享python __init__()的使用注意(python里面init),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:python __init__ __new__,python __init__ __new__,python里面__init__.py,python __init__ py,python __init__ py,python的__init__(),python __init__ __new__,python __init__ __new__,内容如对您有帮助,希望把文章链接给更多的朋友!

python __init__()的使用注意(python里面init)

使用注意

1、init()方法在创建一个对象时默认被调整,不需要调整。

2、init(self)中的self参数不需要开发者传输,python解释器会动员传输当前对象。

实例

classWasher():def__init__(self)->None:self.height=1000self.width=10defwash(self):print(f'宽度是:{self.width},高度是{self.height}')haier1=Washer()print(haier1.height)print(haier1.width)haier1.wash()

以上就是python __init__()的使用注意,希望对大家有所帮助。更多Python学习指路:Python基础教程

本文链接地址:https://www.jiuchutong.com/zhishi/310475.html 转载请保留说明!
下一篇链接:https://www.jiuchutong.com/zhishi/310476.html
免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络