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)

相关推荐
ccino .9 小时前
awvs_json_word.py 使用说明手册
json·word
richard_yuu9 小时前
JSON vs XML vs 二进制:3种序列化终极选型
xml·c++·qt·学习·json
用户7783366132111 天前
SERP 返回 JSON 用 Pydantic 强校验:类型安全解析
json
灵析表格1 天前
灵析表格财务函数深度实用性分析与实操教程
开发语言·ai·json·excel·wps
青 春 记 忆1 天前
零基础入门python07:让程序记住数据——JSON文件和异常处理
开发语言·windows·python·json·python3.11
2603_965148112 天前
如何解析JSON数据?API返回的商品信息处理教程
开发语言·数据库·python·自动化·json·api
鬼手点金2 天前
Scrapy 网络爬虫框架
爬虫·python·scrapy·ajax·html·json·requsts
鬼手点金2 天前
Scrapy + Playwright 完整示例(JS 动态渲染网页)
开发语言·javascript·爬虫·python·scrapy·html·json
AlfredZhao2 天前
VS Code 一键美化 JSON:不用安装插件
json
zhanghaha13143 天前
Python进阶教程:6_JSON 数据解析 —— 新手完全指南
开发语言·python·json