This is my code:
import requests import json import re requisicao = requests.get('https://api.binance.com/api/v3/ticker/price?symbol=ETHUSDT') cotacao = json.loads(requisicao.text) print ('BINANCE BTC = U$',cotacao)
OUTPUT
{'symbol': 'ETHUSDT', 'price': '2013.44000000'}
and that is not what I wanted,
This is what I wanted it to look like: 2013.44000000
, only the digits
Advertisement
Answer
You need to define which object you want from the response, for this case we have two options:
cotacao['symbol']
or
cotacao['price']
So, for your need we can define it like this:
import requests import json import re requisicao = requests.get('https://api.binance.com/api/v3/ticker/price?symbol=ETHUSDT') cotacao = json.loads(requisicao.text) print (cotacao['price'])
Output:
2013.44000000