Python dictionary.keys() error
-
12-11-2019 - |
문제
I am trying to use the .keys()
and instead of getting a list of the keys like
always have in the past. However I get this.
b = { 'video':0, 'music':23 }
k = b.keys()
print( k[0] )
>>>TypeError: 'dict_keys' object does not support indexing
print( k )
dict_keys(['music', 'video'])
it should just print ['music', 'video'] unless I'm going crazy.
What's going on?
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow