{
"test": [
{
"customer": "test1",
"type": [
"windows"
],
"contact": [{
"name": "a",
"email": "@gmail.com",
"phone": null ,
"remarks": null
}]
},
{
"customer": "test2",
"type": [
"android"
],
"contact": [{
"name": "b",
"email": "@gmail.com",
"phone": "010-0000-0000",
"remarks": null
}]
},
{
"customer": "test3",
"type": [
"android"
],
"contact": [{
"name": "a",
"email": "@naver.com",
"phone": null,
"remarks": null
}]
}
]
}
import json
with open('test.json', 'rt', encoding='UTF8') as f:
content = json.load(f)
email_list = [ x for x in content['omnidoc']['contact']['email'].keys()]
파이썬에서 json파일의 email데이터만 리스트로 가져오고 싶은데 어떻게 해야할까요? 그리고 중복제거까지 하고싶어요.
여기서는 이런 오류가 나오네요.
TypeError: list indices must be integers or slices, not str