파이썬 2.7에서 비즈니스 데이터 분석 애플리케이션을 프로토 타입 화하려고합니다. 코드는 다음과 같습니다.API에서 데이터를 가져 오면 TypeError : unhashable type : 'dict'
import urllib2
import json
url = 'http://dev.c0l.in:8888'
api = urllib2.urlopen(url)
data = json.load(api)
for item in data:
print item[{'sector':'technology'}]
기술 데이터베이스의 데이터를 가져와야합니다 그 대신에 내가 얻는다
Traceback (most recent call last):
File "C:\Users\gniteckm\Desktop\all2.py", line 9, in <module>
print item[{'sector':'technology'}]
TypeError: unhashable type: 'dict'
'item'은 사전입니다. 너 뭐하려고? JSON 객체 키는 어쨌든 * strings * 일 수 있습니다. –
'dict' 타입은 해쉬 할 수 없으며 인덱스처럼 사용할 수 없습니다.'data'는 어떻게 생겼습니까? – Kasramvd
데이터를 가져 오거나 데이터를 업데이트하려고합니까? –