목록메서드 (1)
Allen's 데이터 맛집
[Python] 기초문법 : 클래스와 메서드
클래스 파이썬에서 클래스는 객체 지향 프로그래밍 (OOP)의 기본 요소 중 하나입니다. 클래스는 속성(attribute)과 메서드(method)를 포함하는 데이터 구조를 정의합니다. 속성은 클래스의 상태를 나타내고, 메서드는 클래스의 동작을 정의합니다. class AttackUnit : def __init__(self,name, hp, damage): self.name = name self.hp = hp self.damage = damage def attack(self, location): print('{0} : {1} 방향으로 적군을 공격 합니다. [공격력 {2}]'\ .format(self.name,location, self.damage )) def damaged(self, damage): print..
Programming/Python
2023. 11. 20. 01:46