python为类定义构造函数
生活随笔
收集整理的這篇文章主要介紹了
python为类定义构造函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用python進行OO編程時, 經常會用到類的構造函數來初始化一些變量。
class FileData:
??? def __init__(self, data, name, type):
??????? self.bits = base64.encodestring(data)
??????? self.name = name
??????? self.type = type
其中self類似c++或者c#的this指針。
class FileData:
??? def __init__(self, data, name, type):
??????? self.bits = base64.encodestring(data)
??????? self.name = name
??????? self.type = type
其中self類似c++或者c#的this指針。
轉載于:https://blog.51cto.com/muzizongheng/1332963
總結
以上是生活随笔為你收集整理的python为类定义构造函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到跟男朋友接吻是什么意思
- 下一篇: 开源自己用python封装的一个Wind