Reputation: 925
I am trying to parse a plist pl
below, am able to parse the keys in ["IOKitPersonalities"]["UART"]["ProductFWMapping"]
however am NOT able to print the corresponding Firmware
values and running into below error?how do I print all the Firmware values,I have the expected output aswell below?
pl = {'IOKitPersonalities': {'UART': {'ProductFWMapping': {'D321': {'Firmware': 'C-4377__s-B2/aladdink.trx'}, 'J318': {'Firmware': 'C-4377__s-B2/monstrob.trx'}, 'D331': {'Firmware': 'C-4377__s-B2/geniek.trx'}}}}, 'NSHumanReadableCopyright': u'Copyright \xa9 2013 Company Inc. All rights reserved.'}
for hw in pl["IOKitPersonalities"]["UART"]["ProductFWMapping"]:
print hw
for hw in pl["IOKitPersonalities"]["UART"]["ProductFWMapping"]:
print hw['Firmware']
Error:-
print hw['Firmware']
TypeError: string indices must be integers, not str
Expected output:-
['D321','J318','D331']
['C-4377__s-B2/aladdink.trx','C-4377__s-B2/monstrob.trx','C-4377__s-B2/geniek.trx']
Upvotes: 0
Views: 54
Reputation: 325
hw is just the key. it should be
for hw in pl["IOKitPersonalities"]["UART"]["ProductFWMapping"]:
print pl["IOKitPersonalities"]["UART"]["ProductFWMapping"][hw]['Firmware']
Upvotes: 1