In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to use super in python". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use super in python" can help you solve the problem.
Specific steps for use:
1. First open the python editor and create a new python project.
2. Use the super function to call the parent class directly in the python project.
Sample code:
#! / usr/bin/python
#-*-coding: UTF-8-*-
Class FooParent (object):
Def _ init__ (self):
Self.parent ='I\'m the parent.'
Print ('Parent')
Def bar (self,message):
Print ("s from Parent" message)
Class FooChild (FooParent):
Def _ init__ (self):
# super (FooChild,self) first finds the parent class of FooChild (that is, class FooParent), and then converts the object of class FooChild into the object of class FooParent
Super (FooChild,self). _ _ init__ ()
Print ('Child')
Def bar (self,message):
Super (FooChild, self) .bar (message)
Print ('Child bar fuction')
Print (self.parent)
If _ _ name__ = ='_ _ main__':
FooChild = FooChild ()
FooChild.bar ('HelloWorld')
Output result:
Parent
Child
HelloWorld from Parent
Child bar fuction
I'm the parent.
This is the end of the content about "how to use super in python". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.