How to use object.__dict__ and instance.__class__
This article mainly explains "object.__ dict__ 、instance.__ How to use class__, interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "object.__ dict__ 、instance.__ class__how to use it!
Code display:
# class Person():# class Person(object):# class Person:class Person: # class Person(object): #class Person: # class Person(): All three are possible '' Define base class Person'' def_init__(self, name, age):'' Initialize attribute name and age'''self.name = name self.age = age def printInfo(self):print ('---I am an instance object of type:{0:^35} ---My name is: {1:{3}