2019.8.8 python day03

 

Basics:

  • % S: string concatenation and
  • % D: integer and splicing
  • % F: float and splicing
  • %: Remainder
  • //: divisible
  • **: square

Static call:

  • @staticmethod

Comparison of static methods and the like, Python may also be defined in the class categories, as follows:

  • @classmethod
    • Get Class itself (cls) attributes, and can be changed.
      A classmethod modifiers need not instantiate the corresponding function, no self parameters, but the first parameter is a required parameter cls own class, the class may be property called the method of the class, instance objects and the like

inherit

  • Class name __init __ (self)
  • Provide information to inherit what we call the parent class; we call it a subclass inherits get information. In addition to the subclass inherits the properties and methods of the parent class provides, you can also define their own unique properties and methods, so the analogy more sub-class has the ability to parent.
  • In the class name written on the inherited class.
  • Private variables can not be inherited

And a list generator formula

  • List of formula:
    • Advantages: speed calculation
    • Disadvantages: wasteful memory

 

  • Builder:
    • Advantages: saving memory space
    • Disadvantages: slow calculation

 Decorator

 

Guess you like

Origin www.cnblogs.com/violet23/p/11323426.html