Python

class self

parkit 2019. 10. 26. 15:28
728x90
반응형

class self





1
2
3
4
5
6
7
8
9
10
11
12
13
class person :
    def __init__(self, name, age = 10) :
        #print(self, 'is generated')
        self.name = name
        self.age = age
        
p1 = person('Bob'30)
p2 = person('Kate'20)
p3 = person('Candy')
 
print(p1.name, '은 ', p1.age, '살이다.')
print(p2.name, '은 ', p2.age, '살이다.')
print(p3.name, '은 ', p3.age, '살이다.')
cs




728x90
반응형