반응형
딕셔너리 내부의 모든 string key를 int로 변경하는 함수이다.
{'1' : '123', '2' : '1234'} >> {1 : '123', 2: '1234'}
def dict_str_key_to_int(target_dict):
return {int(k) if k.isnumeric() else k :v for k,v in target_dict.items()}
반응형
'프로그래밍 > python' 카테고리의 다른 글
| [selenium] 크롤링으로 가져온 문자열이 깨져있는 경우 (0) | 2022.06.21 |
|---|---|
| [selenium] 셀레니움으로 부모 webelement 찾기 (0) | 2022.06.21 |
| [selenium] 요소가 존재하지만 클릭 할 수 없는 오류 'Element is not clickable at point' (1) | 2022.06.17 |
| [Python] 구글 드라이브 API로 폴더 만들어보기 (0) | 2022.06.14 |
| python dictionary to json (0) | 2022.06.14 |