Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the super () function in Python

Shulou Source: shulou.com Published: 2022-06-02 10:22:45 10月03日 Update

I believe many inexperienced people don't know what to do about how to use the super () function in Python. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

The code experiment shows:

# inheritance relationship object-> Person-> Student-> SchoolBoy# python2 Syntax: # class Person (object): # python3 Syntax: # class Person (): class Person (): # class Person (object):''define the base class Person''' def _ init__ (self, name, age):' 'initialize the properties name and age'''self.name = name self.age = age def printInfo (self): print ('-- I am an instance object Belongs to type: {0: ^ 35}-my name is: {1: {3}

Tags: Name instance object age type syntax property function content subclass method more problem pockmarked helpless for this individual code reason for this Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Linux Microsoft NVidia