반응형 Dict key1 How to get a dict key in the list Example: interfaceList = [{"Gi 0/1" : "Switch 1"}, {"Gi 0/2" : "Switch 2"}] I want to get soley a str-type key from the list to look up a list of dict, which are Gi 0/1 and Gi 0/2. But, if I iterate and print the interfaceList and using keys() functions for elem in interfaceList: print(elem.keys()) I get a dict_keys-type key instead like the right below output. [Output] dict_keys(['Gi 0/1']) dic.. 2020. 6. 13. 이전 1 다음 반응형