Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the super () function in Python

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report