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 |
Tags
- 오류
- JSON
- Python
- Linux
- 채보
- windows forms
- OpenCV
- 핑거스타일
- Selenium
- pytorch
- pip
- C++
- SSH
- pandas
- YOLO
- ubuntu
- C
- Docker
- VS Code
- 기타 연주
- Numpy
- error
- mysql
- 프로그래머스
- C#
- 컨테이너
- Visual Studio
- LIST
- paramiko
- label
Archives
- Today
- Total
목록attrgetter (1)
기계는 거짓말하지 않는다
Python operator itemgetter, attrgetter
Python에서 정렬 함수를 사용할 때 itemgetter를 이용하여 정렬 key 기준을 쉽게 가져올 수 있다. class 인스턴수 변수를 기준으로 key 값을 가져오려면 attrgetter를 사용한다. lambda로 대체 가능하다. from operator import itemgetter # list itemgetter temp_list = [(10, "C"), (20, "A"), (30, "B")] result = sorted(temp_list, key=itemgetter(0)) print(result) # dict itemgetter temp_dict = [{"number": 10, "string": "C"}, {"number": 20, "string": "A"}, {"number": 30, "st..
Python
2023. 4. 15. 16:32