读取json文件,json line格式、 json list格式

python 复制代码
import json
from tqdm import tqdm

# json line
with open(file_name, "r", encoding='utf-8') as f:
    lines = f.readlines()
    for line in tqdm(lines):
        json_line = json.loads(line)
        print(json_line)

# json list
with open(file_name, 'r', encoding='utf-8') as f:
    json_list = json.load(f)
    for json_line in tqdm(json_list):
        print(json_line)
相关推荐
im_AMBER1 小时前
weather-app开发手记 02 JSON基础 | API 调用 400 错误修复 | JWT 认证问题
笔记·学习·json·axios·jwt
Irene199121 小时前
Prettier 配置文件 .prettierrc.js 和 .prettierrc.json 的区别
javascript·json
23G1 天前
Fastjson转换jsonStr时设置SerializerFeature.DisableCircularReferenceDetect不生效
json
函数的彼端1 天前
iOS Model Generator - 让 JSON 转模型变得简单高效
ios·json·cocoa
吕吕-lvlv1 天前
实现轻松存取JSON的小工具
json
web前端进阶者1 天前
electron-vite报错Unexpected end of JSON input
javascript·electron·json
亚林瓜子1 天前
在AWS Athena中使用json_extract_scalar函数对某个json字段进行过滤和分组统计
sql·json·aws·athena
micro_cloud_fly1 天前
langchain langgraph历史会话的 json序列化
python·langchain·json
doupoa1 天前
VitePressv2.0 + TailwindCSSv4.1 集成方案
typescript·前端框架·json·html5·postcss
时光轻浅,半夏挽歌2 天前
python不同格式文件的读写方式(json等)
python·json