Python/Intermediate (18) 썸네일형 리스트형 [Python] Class(2) - self, 매직 매소드 # Chapter02-02# 파이썬 심화# 객체 지향 프로그래밍(OOP) -> 코드의 재사용, 코드 중복 방지 등# 클래스 상세 설명# 클래스 변수, 인스턴스 변수# 클래스 재 선언class Car(): # Doctring """ ~ """ """ Car Class Author : Kim Date : 2019.11.08 사용법: """ # 클래스 변수, 모든 인스턴스가 공유함. car_count = 0 # self 는 인스턴스 입니다. def __init__(self, company, details): self._company = company self._details = details Car.car_coun.. [Python] Class(1) - Basic print(car1) 과 print(car_list) 의 차이에 주의할 것, 객체를 직접출력할때와 객체를 리스트에 넣어서 출력할때 차이 있음.print(car1) - str 로 출력print(car_list) - 객체를 리스트에 넣어서 출력하면 __repr__ 로 출력 class Car(): def __init__(self, company, details): self._company = company self._details = details def __str__(self): # 매직 메소드, 간단한 사용자 레벨의 출력 return 'str : {} - {}'.format(self._company, self._details) # __str__ 함수를 .. 이전 1 2 3 다음