0

I am trying to separate this response in python:

{"token":"20906d71687539386c766a696a6a6231616f6c62736d71687539386c67697576307734313339363936363463366336363533373434333536343134353337366237613339343233303664373236613737353935613431363436 39333634383331333533383335333033393337333733383331323061623564356233373030646337383534656466383235616134613636353661396439363662326633313532396165353865393836636332363038303736643135383530 3937373831","landed_at":"1585097781"}

I want to make a variable for token and have it hold the "token" value and a variable for landed_at and have it hold that value.

4

2 Answers 2

0

You can do that by accessing the simple dictionary object you are working with. Assuming your response is the object resp:

resp = {"token": "1221234213", "landed_at" : "1585097781"}
token = resp["token"]
landed_at = resp["landed_at"]

This is how you access the values in a dictionary, by calling the key of that value.

Sign up to request clarification or add additional context in comments.

Comments

0

You should be able to do this using the json lib.

import json
raw = '{"token":"20906d716875391","landed_at":"1585097781"}'
jsonObj = json.loads(raw)
token = jsonObj['token']
landedat = jsonObj['landed_at']
token
#'20906d716875391'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.