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