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
- 프로그래머스
- pytorch
- pandas
- YOLO
- mysql
- C++
- C
- JSON
- 기타 연주
- C#
- 명령어
- nvidia-smi
- pip
- label
- paramiko
- 컨테이너
- Visual Studio
- VS Code
- Numpy
- SSH
- ubuntu
- Python
- OpenCV
- Linux
- error
- Selenium
- 오류
- Docker
- 채보
- windows forms
Archives
- Today
- Total
목록Sort (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