기초 _데이터 타입, 문법] 메모리

  • 데이터 확인
  • 데이터 리셋
%whos 데이터 확인
%reset 데이터 리셋

 

'Python > 기초_데이터 타입, 문법' 카테고리의 다른 글

기초_데이터 타입, 문법] 클래스  (0) 2023.09.09

클래스 개념

class, self, __init__() 클래스는 사용자 정의 데이터 타입
   
클래스선언(코드작성) class Marine:
    health, ap = 40, 5
    def attack(self, target) :
        target.health -= self.ap
   
객체 생성 m1, m2 = Marine(), Marine()
m1.health, m1.ap, m2.health, m2.ap
   
생성자 메서드 스페셜 메서드 중 하나(특별한 기능을 하는 앞뒤로 __가 있는 메서드)

__init__() : 객체를 생성할 때 실행되는 메서드
   
클래스 선언(코드 작성) class Marine:
    def __init__(self, health, ap =5):
        self.health, self.ap = health, ap

    def attack(self, target):
        target, health -= self.ap
   

'Python > 기초_데이터 타입, 문법' 카테고리의 다른 글

기초_데이터 타입, 문법] 메모리  (0) 2023.09.09

+ Recent posts