instancemethod 썸네일형 리스트형 python 클래스(class), 생성자, 상속 연습문제② Person클래스를 만들면 기본생성자가 만들어진다. class Person: def __init__(self): print(self, '생성됨') self.name = '이순신' self.age = 30 p1 = Person() p2 = Person() print(p1) print(p2) print(p1.name, p2.name) 파라미터가 들어가는 생성자로 다른 객체를 만들 수 있다. class Person: def __init__(self, n, a): self.name = n self.age = a p1 = Person('차무식', 40) p2 = Person('마동석', 50) p3 = Person('레오나르도 디카프리오', 66) print(p1) print(p2) print(p3) print(.. 더보기 이전 1 다음