Class is created and calls

1  class Computer:    # create a class called, pay attention to the class name first letter should be capitalized! 
2  
. 3      Screen = True            # assignment statement and, creating class attributes 
. 4      DEF Start (Self):           # Method class is created, do not leak Self 
. 5          Print ( ' the computer is being powered ...... ' )
 . 6   
. 7 my_computer Computer = ()    # class instantiation 
. 8  Print (my_computer.screen)     # instance calls the class attributes 
. 9 my_computer.start ()             # method call class (no reference transfer tube self)    

Guess you like

Origin www.cnblogs.com/lewuyou/p/11520713.html
Recommended