Realize function
Convert a class object (instance) into a dictionary
Implementation code
# 自定义类
class MyClass:
# 初始化
def __init__(self):
self.a = 2
self.b = 'bb'
##########################
# 创建MyClass对象
myClass = MyClass()
# 添加数据c
myClass.c = 123
myClass.a = 3
# 对象转化为字典
myClassDict = myClass.__dict__
print(myClassDict)
achieve effect
During my postgraduate study, I published 5 papers related to SCI data mining. Now a research institute is engaged in scientific research related to data mining. I have a certain knowledge and understanding of data mining. I will combine my own scientific research practice experience to share from time to time about python machine learning and deep learning. , Basic knowledge and cases of data mining.
Committed to only being original, understanding and learning in the simplest way, pay attention to V subscription number: data miscellaneous forum , contact me for more skills and source code.