로딩
요청 처리 중입니다...

[python] TypeError: 'dict_items' object does not support indexing

 [python] TypeError: 'dict_items' object does not support indexing

#python #dictionary #indexing #pythonerror 안녕하세요 오늘은 파이썬에서 딕셔너리를 사용할 때, indexing으로 접근가능한 방안 알려드리겠습니다. a = '안녕하세요' dictionary = dict() for i in a: if i in dictionary: dictionary[i] += 1 else: dictionary[i] = 1 print(dictionary) #{'안': 1, '녕': 1, '하': 1, '세': 1, '요': 1} 다음과 같이 딕셔너리를 만들었다고 가정합니다. 그럼 여기서 이제 리스트처럼 인텍싱을 사용해서 접근하고 싶으면 이렇게 타이핑 치시겠죠. b = dictionary.items() print(b[0]) Traceback (most recent call last): File "", line 1, in TypeError: 'dict_items' object is not subscriptabl...

# dictionary # indexing # python # pythonerror