Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use object.__dict__ and instance.__class__

Shulou Source: shulou.com Published: 2022-06-01 08:14:39 10月02日 Update

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}

Tags: Pockmarked content name instance object age type learning practical deeper personal code interest writing practical practical attribute console easy to operate file Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei MySQL Linux Redmi