In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what are the points for attention of python methods". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what are the points for attention of python methods?"
1. @ classmethod must be above the method.
2. The first cls must have, which refers to the class object itself.
3. Accessing instance properties and instance methods in class methods can lead to errors.
4. When a subclass inherits a parent method, cls is a subclass object, not a parent object.
Call class method format: "class name. class method name (parameter list)".
Values cannot be passed by cls in the parameter list.
Example
Class Person: # Class attribute school = "Sino-Canada Fenghua International School" tuition = 100000 count = 0 # instance attribute def _ _ init__ (self,name,age Gender): self.name = name self.age = age self.gender = gender Person.count = Person.count+1 @ classmethod def printSchool (cls): print (cls) print (cls.school) # instance method def get_score (self): print ("name: {0}" Age: {1}; gender: {2} ".format (self.name,self.age,self.gender) stu1 = Person (" sue ", 22," male ") stu1.get_score () Person.printSchool () so far, I believe you have a deeper understanding of" what are the points for attention of python methods ". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.