Python Seventh Day

Source: Internet
Author: User

How time is expressed

1. Time stamp

2. Formatted string

3. Structured time

Calculator code

Object has a class object pointer, and if the method that is called does not exist in the object, it points to the method that creates the object's class, and the variable that is required to create the object's class in the object

Inheritance of Classes

1. Java, C # does not support multiple inheritance

2, the classic class multi-inheritance depth first (when there is duplication, the first to inherit the deepest)

3, new type multi-inheritance breadth first (when there is repetition, inherit the nearest)

Class Member

Field

Normal field

object is defined in the

Static fields

defined in a class

Method

Common methods

Object trigger, at least one

Class method

With the adorner (Classmethod), and the parameter cannot be the self must be a CLS class trigger

Static methods

with the adorner (Staticmethod), and the parameters can be arbitrarily added to trigger the class

Attribute (just a noun, a modified method)

Normal properties

@property to define

The call is missing a parenthesis.

The new class also supports setting, fetching, and deleting property values

static field + __ becomes private (two underscore)

Obj._foo__name Object Point _ Class name __ Member

Summarize

1, object-oriented three major features

Encapsulation, inheritance, polymorphism (not much ....) )

2. Python Package

A, multiple methods common a set of variables, variables encapsulated into the object

b, write to the method oh

3. Inheritance

A, base class, and derived class

B, multiple inheritance Oh (Python special)

C, new class, classic class

D, breadth first (rule), depth first = = "Interview

4. polymorphic

Wash and sleep, this is not science oh, not fun ....

4. Class, Object, memory

5. Class Members

A, field

Normal, static

B, Methods

The normal method object triggers at least one self value to be automatically assigned to the current object

class method class fires only one CLS value is automatically assigned to the current class

static method class triggers arbitrary arguments

C, properties

Common attributes (variant of method, which becomes similar when accessed and field)

@property

Data = Property (method name)

Obj. Data = Executes the method and gets the return value of the method

Properties in the new class

@property

@ Method name. Setter

@ Method name. deleter

6. Class member Modifiers

1, total, private (two underscore start)

Private, only internal access

Private non-access: Object Point _ Class name __ Member

7, Egg pain

obj = Foo ()

obj () ==>__call__

8, __dict__

Viewing object variables

View variables for a class

Method __str__

Friendly form output

1. Calculator

2. Game Life

Object-oriented ....

Pickle can serialize objects

obj = Foo ()

3, contact Paramiko configpaser (optional)

Python Seventh Day

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.