728x90
class
-
Python Class 기초AI/Python 2020. 12. 18. 14:52
프로그램언어를 다루면 클래스를 대부분 사용한다. Python에서의 클래스 사용법을 간단하게 연습해 보았다. #Class 클래스 class Pet: # 클래스 선언(클래스명은 대문자로 시작) color = "" kind = "dog" character = "home_grown" strength = 100 def walk(self, do): self.strength = self.strength - do def eat(self, do): self.strength = self.strength + do def sleep(self, do): self.strength = self.strength + do poodle = Pet() poodle.color = 'brown' poodle.walk(15) print(poo..