I am using Python for the first time to create a simple JSON parser. However, when printing the JSON data to the console, it includes many extra brackets and other symbols that are unwanted. I am also running Python 2.7.10.
import json
from urllib2 import urlopen
response = urlopen("https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json")
source = response.read()
# print(source)
data = json.loads(source)
# print(json.dumps(data, indent=2))
usd_rates = dict()
for item in data['list']['resources']:
name = item['resource']['fields']['name']
price = item['resource']['fields']['price']
usd_rates[name] = price
print(name, price)
And the output is as follows:
When I try to change the python version to 3.7.10: