Answer the question
In order to leave comments, you need to log in
What is the best way to handle exceptions?
Hey!
There is JSON at the input, which has its own structure, but the keys may not have values, for example:
With data, one of the keys looks like this:
"weight":[{"type":1,"value":31.0,"measurement":"g"}]
"weight":[]
Answer the question
In order to leave comments, you need to log in
Let weight be a key in some data, then:
if 'weight' in data:
for w in data['weight']:
t = w['type']
# и т.д.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question