0
저는 파이썬과 프로그래밍에 대한 완전한 아마추어입니다. 서버의 JSON 데이터 파일에서 데이터 목록을 읽으려고합니다. 다음과 같은 오류가 발생합니다 :Python 및 JSON 구문 분석. TypeError :리스트 인덱스는 str이 아닌 정수 여야합니다.
TypeError: list indices must be integers, not str
나는 어떤 종류의 변화가 필요한이 문장으로 돌아갈 것이지만 나는 그것이 무엇인지 알지 못한다.
def grabDeviceIDs():
devices=[];
## parse the list
for deviceListJSON in (getDeviceListFromserver()['mobile_device_group']['mobile_devices']['mobile_device']):
d = Device()
d.id = deviceListJSON.get('id')
devices.append(d)
print "Found " + str(len(devices)) + " devices."
return devices
아이디어가 있으십니까?
json이 반환 한 예제를 게시 할 수 있습니까? –
구조에 사전이 있다고 생각되는 목록이 있습니다. 우리는 그 구조를 볼 필요가 있습니다. –
특히,'mobile_devices' 키는 마치리스트를 참조하는 것처럼 들립니다. –