Fixed format of object-oriented definitions and calls

class class name: 
DEF the __init __ (Self, parameter 1, parameter 2):
Self properties of the object 1 = parameter 1.
Self properties of the object 2 = parameter 2.

DEF method name (Self): Pass

DEF method name 2 (self): pass

object name = name of the class (2) # is the object instance represents a specific thing
# class name (): + class name in parentheses is an instance of a class, a method is equivalent to calling the __init__
# pass parameters in parentheses , parameters do not need to pass self, other participants in the form of one-init
# result returns an object
object name. properties object # 1 to view the object directly with the object name. attribute name to
an object name. method name ( ) # call the class method, direct method name with the name of the object () to

Guess you like

Origin www.cnblogs.com/li33232/p/11502772.html