1

I have this Python script:

import json
from cinbase.walle.client import Client

apiKey = foo
mysecret = bar

client = Client( apiKey, mySecret )
price = client.get_spot_price(currency_pair = 'BTC-EUR')

This is my output:

{
"data" :{
             "amount": "123455"
             "currency": "EUR"
 }
}

How to get only "amount" value?

2
  • output_obj['data']['amount'] Commented Jun 21, 2021 at 8:47
  • how did you produce the output? did you just print the "price" variable? Commented Jun 21, 2021 at 8:54

1 Answer 1

2

In python, this data type is called a dict (short for dictionary). You can index this object as follows:

value = your_dict[key]

So in your case specifically:

amount = price["data"]["amount"]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for explaination @ahammond! I have solved

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.