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 |
Tags
- Docker Desktop
- synchronized
- 파이썬
- join()
- array
- AssertJ
- SpringBoot
- StringBuilder
- SSL
- 배열
- 자바스크립트
- GIT
- 프로그래머스스쿨
- thread
- 자바
- 저장소
- 클래스
- JS
- 메소드
- event
- Dict
- Swing
- docker
- class
- Java
- 객체
- Python
- JavaScript
- 스프링부트
- c#
Archives
- Today
- Total
목록연산자 (1)
정리노트
[파이썬/python] [클래스] 특수 메소드
print(객체) 이것만으로 객체안의 정보들을 알 수 있다면 편할 것이다. __str__() 메소드를 class 안에 정의하면 가능하다. class Count: def __init__(self, num): self.num = num def __eq__(self, other): return self.num == other.num def __str__(self): message = "담긴숫자: " + str(self.num) # 문자열과 합치기 위한 데이터타입 문자열 변환 함수str return message num1 = Count(10) print(num1) // 담긴숫자: 10 객체를 연산할 수 있는 특수 메소드 예시) __eq__ 메소드 ( == 를 사용하는 메소드) class Count: def __..
프로그래밍/Python
2022. 9. 28. 01:11