Study Notes (05): 21 days clearance Python (Video Lesson only) - Defines the class

Learning immediately: https://edu.csdn.net/course/play/24797/282185?utm_source=blogtoedu

Why output [None] have it? ? ? ? 

Random Import 


class testA: 
    Print ( "testA category") 


class testB: 
    FSTR = '% S Test'% 'class B' 
    Print (FSTR) 


class TestC: 
    Print ( 'TestC class') 

    DEF testCfun (Self): 
        the self.name = 'TestC' 
        self.age the random.randint = (0, 10) 
        return Print ( 'name:% s, Age: S%'% (the self.name, self.age)) 

    DEF testCfun2 (Self): 
        Print ( ' returns the random number S% '% the random.randint (0, 10)) 


testA.name = "testAAA" 
testB.name =' testBBB ' 

del testB.name 

Print (testA.name) 
Print (testB.fstr) 
Print (TestC ( ) .testCfun ()) 
Print (TESTC ().

 

Output:

testA class
testB class
testC class
testAAA
testB class
name: testC, Age: 3
None
Returns a random number 0
None
 

Published 25 original articles · won praise 4 · Views 611

Guess you like

Origin blog.csdn.net/happyk213/article/details/105135407