labelme 修改后的json文件 ,imageData 值改为null的脚本

import os

import json

def set_image_data_to_null(directory):

for filename in os.listdir(directory):

if filename.endswith('.json'):

file_path = os.path.join(directory, filename)

with open(file_path, 'r', encoding='utf-8') as file:

data = json.load(file)

将 imageData 设置为 None,在JSON文件中会显示为 null

if 'imageData' in data:

data['imageData'] = None

保存修改后的文件

with open(file_path, 'w', encoding='utf-8') as file:

json.dump(data, file, indent=4)

替换以下路径为你的JSON文件所在的文件夹路径

directory_path = 'path_to_your_directory'

set_image_data_to_null(directory_path)

相关推荐
jieyucx6 小时前
Go 语言 JSON 序列化与反序列化
开发语言·golang·json·序列化
xwjalyf7 小时前
javascript数组 forEach,filter,some,every,map,find,reduce的用法与区别
开发语言·javascript·json·ecmascript
吾爱测试8 小时前
LZCCB_CREDIT_DEMO.json
json
明月_清风1 天前
文本序列化格式全景——JSON、XML、YAML 的适用边界与选型
后端·json
明月_清风1 天前
为什么需要序列化?——从内存对象到字节流,理解数据交换的本质
后端·json
ZC跨境爬虫2 天前
模块化烹饪小程序开发日记 Day7:(菜谱详情接口开发与JSON数据读取全流程)
前端·javascript·css·ui·微信小程序·json
alwaysrun2 天前
C++之现代易用JSON库nlohmann
c++·json·序列化·nlohmann
lifejump3 天前
JSON技术解析
json