需要在 Python3 中解析 JSON
need to parse JSON in Python3
我是 Python 的新手,需要解析日期和 '4.来自以下 JSON 的关闭'。非常感谢您提供如何以 pythonic 方式执行此操作的指示。
{'2017-01-24': {'1. open': '207.8600',
'2. high': '209.4000',
'3. low': '207.7479',
'4. close': '208.9700',
'5. adjusted close': '208.0046',
'6. volume': '1940125',
'7. dividend amount': '0.00',
'8. split coefficient': '1.0000'},...
您可以这样解析 JSON:
import json
from pprint import pprint
with open('path_of_file.json') as data_file:
data = json.load(data_file)
pprint(data)
我是 Python 的新手,需要解析日期和 '4.来自以下 JSON 的关闭'。非常感谢您提供如何以 pythonic 方式执行此操作的指示。
{'2017-01-24': {'1. open': '207.8600',
'2. high': '209.4000',
'3. low': '207.7479',
'4. close': '208.9700',
'5. adjusted close': '208.0046',
'6. volume': '1940125',
'7. dividend amount': '0.00',
'8. split coefficient': '1.0000'},...
您可以这样解析 JSON:
import json
from pprint import pprint
with open('path_of_file.json') as data_file:
data = json.load(data_file)
pprint(data)