你可以使用dict理解来
output
:
dct = {
"Africa": {
"invitee_event_type_page": {"Total Events": "194"},
"invitee_meeting_cancelled": {"Total Events": "9"},
},
"Asia": {
"invitee_event_type_page": {"Total Events": "127"},
"invitee_meeting_scheduled": {"Total Events": "16"},
},
}
out = [
{
f"{k} - {kk}": int(vv["Total Events"])
for k, v in dct.items()
for kk, vv in v.items()
}
]
print(out)
打印:
[
{
"Africa - invitee_event_type_page": 194,
"Africa - invitee_meeting_cancelled": 9,
"Asia - invitee_event_type_page": 127,
"Asia - invitee_meeting_scheduled": 16,
}
]