로딩
요청 처리 중입니다...

[python] dictionary split by value

 [python] dictionary split by value

#python #dictionary #split 안녕하세요 오늘은 python에서 dictionary를 value값을 기준으로 쪼개는 방법을 알려드리겠습니다. python으로 작업하다보면 딕셔너리를 많이 사용하게 되는데요. 본인이 원하는 key & value만 넣고 싶은 경우도 많이 생길것 같습니다. data = {"FP3": 1, "FP4": 2, "X": 3, "Y": 4, "Foo": 5} print('before : ',len(data)) # before : 5 data2 = {key: data[key] for key, value in data.items() if value >= 3} print('after : ',len(data2)) # after : 3 print(data2) # {'X': 3, 'Y': 4, 'Foo': 5} {key: data[key] for key, value in data.items() if value >= 3} 바로 이 부분이 dictionary를...

# dictionary # python # split