파이썬 혼공파 딕셔너리
-
33 - 딕셔너리 요소 변경 / 추가 / 제거study with Q - 파이썬 2024. 4. 10. 22:04
pro = { "제목" : "우아한 우주", "저자" : "엘라 프랜시스" } #요소의 값을 변경하는 방법 : 걍 다시 넣어주세요 #요소를 추가하는 방법 : 원하는 key와 값을 넣어준다 pro = { "제목" : "우아한 우주", "저자" : "엘라 프랜시스" } #요소 값 변경 pro["저자"] = "엘라 프랜시스 랜더스" #요소 추가 pro["옮긴이"] = "심채경" print(pro) >>> {'제목': '우아한 우주', '저자': '엘라 프랜시스 랜더스', '옮긴이': '심채경'} #요소를 제거하는 방법 :del 키워드를 사용 pro = { "제목" : "우아한 우주", "저자" : "엘라 프랜시스 랜더스", "옮긴이" : "심채경", "가격" : 15800 } del pro["가격"] prin..