N
N
ninja op op2020-06-16 10:57:45
Python
ninja op op, 2020-06-16 10:57:45

How to pull value from PYTHON3 dictionary?

Python3

There are JSON responses from requests.post like this:

new: {
hid: '10101'
}
success: {
hid: '10102'
}

*hid value always changes, and sometimes new and success also change between each other

how do I get the value hid despite the name of the parent, if you can call it that)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
ninja op op, 2020-06-16
@kur4chyt

list(response.values())[0]['hid'] did it like this, it seems to work!

I
Ilkhomjon Matazimov, 2020-06-16
@mr_qpdb

if "new" in data:
  data["new"]["hid"]
elif "success" in data:
  data["success"]["hid"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question