Python读取JSON文件
Python读取json文件主要使用json模块
import xlrd
import requests
import json
import pandas as pd
import os
#循环当前目录下文件
import os
file = r'F:\WorkSpace\demo\Python\ReadJson'
for root, dirs, files in os.walk(file):
if root != file:
break
for file in files:
path = os.path.join(root, file)
fileName= print(path[0:-5]+'\n')
with open(path,'r',encoding='utf8') as fp:
json_data = json.load(fp)
# print('这是文件中的json数据:',json_data['data'])
# print('这是读取到文件数据的数据类型:', type(json_data))
for v in json_data['data']:
print(v['value'])
print(v['analysis_date'])
with open(path,'r',encoding='utf8') as fp:
json_data = json.load(fp)
# print('这是文件中的json数据:',json_data['data'])
# print('这是读取到文件数据的数据类型:', type(json_data))
for v in json_data['data']:
print(v['value'])
print(v['analysis_date'])