딕셔너리 ↔ 자료구조 형변환
#json.dumps(dict,indent) #json.dump(dict, file_pointer) #json으로 형변환 d = {"group1":[ {'name':'Park', 'age':'32', 'sex':'Male'}, {'name':'Cho', 'age':'44', 'sex':'Female'}, {'name':'Kang', 'age':'39', 'sex':'Female', 'married':'No'} ], "group2":[ {'name':'Kim', 'age':'23', 'sex':'Male', 'married':'Yes'}, {'name':'Lee', 'age':'37', 'sex':'Male', 'married':'No'} ], "type": {'a':'employee', 'b':'offi..
2023. 11. 7.
딕셔너리 값 추출 예제2
#아래 딕셔너리에 group1에 {'name':'Park', 'age':'32', 'sex':'Male','married':'Yes'} 추가, type에 {'f':'engineer'} 추가 d = {"group1":[ {'name':'Park', 'age':'32', 'sex':'Male'}, {'name':'Cho', 'age':'44', 'sex':'Female'}, {'name':'Kang', 'age':'39', 'sex':'Female', 'married':'No'} ], "group2":[ {'name':'Kim', 'age':'23', 'sex':'Male', 'married':'Yes'}, {'name':'Lee', 'age':'37', 'sex':'Male', 'married':'No'}..
2023. 11. 7.
딕셔너리 값 추출 예제1
#아래 딕셔너리에서 출력결과와 같이 값 추출 #Name : Kim, Age : 23, Type : office' d = {"group1":[ {'name':'Park', 'age':'32', 'sex':'Male'}, {'name':'Cho', 'age':'44', 'sex':'Female'}, {'name':'Kang', 'age':'39', 'sex':'Female', 'married':'No'} ], "group2":[ {'name':'Kim', 'age':'23', 'sex':'Male', 'married':'Yes'}, {'name':'Lee', 'age':'37', 'sex':'Male', 'married':'No'} ], "type": {'a':'employee', 'b':'office', ..
2023. 11. 7.