Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- RDS
- node
- wetube
- lambda
- flask
- SSA
- pandas
- 파이썬
- Props
- S3
- NeXT
- 채팅
- async
- 중급파이썬
- merge
- socket io
- EC2
- git
- Class
- crud
- docker
- TypeScript
- Vue
- 카톡
- SAA
- AWS
- dict
- react
- 튜플
- MongoDB
Archives
- Today
- Total
목록클래스 변수 (1)
초보 개발자

class Person(): people_cnt = 0 def __init(self,name): self.name = name Person.people_cnt += 1 @classmethod def get_cnt(cls): print(cls.people_cnt) def get_cnt2() print(Person.people_cnt) def get_name(self): print(self.name) kim = Person('kim') lee = Person('Lee') 이러한 클래스가 있다고 가정해보자 기본적으로 people_cnt라는 클래스 변수를 0으로 지정해두었다. 그리고 객체가 생성될 때 인스턴스 메소드 __init__이 실행이된다. self.name(인스턴스 변수)에 name이들어가고 Person..
Python/이것 저것
2021. 12. 26. 17:43