K
K
KEEYN2021-10-07 15:41:21
Python
KEEYN, 2021-10-07 15:41:21

How to take an element from a dictionary in a dictionary?

event_request_body = {
'start': {
'dateTime':convert_datetime(2021, 10, 7, 12, 0),#I want to take this element
'timeZone': 'Europe/Moscow'
},
'end': {
'dateTime': convert_datetime(2021, 10, 7, 14, 30),
'timeZone': 'Europe/Moscow'
},
'summary': 'GYM',
'description': 'apapapapapapapappa'
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kirillinyakin, 2021-10-07
@KEEYN

event_request_body['start']['dateTime']

C
calcium, 2021-10-07
@calcium

You can use So will not throw an exception, in the absence of a key. https://python-reference.readthedocs.io/en/latest/...
event_request_body.get('start').get('dateTime')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question