user3447653 user3447653 - 1 year ago 89
Python Question

Access nested key-values in Python dictionary

I have the following dictionary structure and Iam trying to access the

field. It is like accessing key of keys in Python dictionary:

key: METTS MARK , value: {'salary': 365788, 'to_messages': 807, 'deferral_payments': 'NaN', 'total_payments': 1061827, 'exercised_stock_options': 'NaN', 'bonus': 600000, 'restricted_stock': 585062, 'shared_receipt_with_poi': 702, 'restricted_stock_deferred': 'NaN', 'total_stock_value': 585062, 'expenses': 94299, 'loan_advances': 'NaN', 'from_messages': 29, 'other': 1740, 'from_this_person_to_poi': 1, 'poi': False, 'director_fees': 'NaN', 'deferred_income': 'NaN', 'long_term_incentive': 'NaN', 'email_address':', 'from_poi_to_this_person': 38}

Answer Source

It rather seems that values of your dictionay are dict, and not that the keys are dict. So you can just access as follows:


Please also anonymize the email address in your example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download