当前位置:网站首页>修改VOT2018.json文件,去掉图片路径中的color
修改VOT2018.json文件,去掉图片路径中的color
2022-08-09 11:32:00 【匿名的魔术师】
直接上代码
import json
import os, sys
json_path = 'VOT2018.json'
new_json_path = 'VOT2018_new.json'
txt_path = 'list.txt'
dict = {}
def get_json_data(path): # 修改 删除原json文件中的color
with open(path) as f:
params = json.load(f)
file = open('list.txt')
while 1 :
lines = file.readline(1000)
if not lines:
break
lines = lines[:-1] # 拿出每个视频文件夹的名字
root = (params[lines]['img_names'])
for i in range(len(root)):
kind, color, jpg = root[i].split('/') # 举例 kind :'ants1', color: 'color' , jpg :'00000001.jpg'
root[i] = kind + '/' + jpg # 重写该路径,去掉 color
file.close()
dict = params
# print(dict)
f.close()
return dict
def write_json_data(path, dictionary): # 保存
with open(path, 'w') as r:
json.dump(dictionary, r)
r.close()
if __name__ =='__main__':
dictionary = get_json_data(json_path)
write_json_data(new_json_path, dictionary)OK
边栏推荐
猜你喜欢

ICML 2022 | Out-of-Distribution Detection with Deep Nearest Neighbors

win10 outlook邮件设置

This application has no explicit mapping for /error, so you are seeing this as a fallback

字符串 | 反转字符串 | 双指针法 | leecode刷题笔记

C# async 和 await 理解

Semaphore SIGCHLD use, how to make the parent that the child performs over, how to make the distinction between multiple child processes. The end

排序--快排(图解)

API接口是什么?API接口常见的安全问题与安全措施有哪些?

结构体变量的首地址获取注意事项

PTA 实验7-5 输出大写英文字母(10 分)
随机推荐
PTA习题 分类统计字符个数(C)
es6对象迭代器iterator
enum in c language
防止数据冒用的方法
PTA习题 三角形判断
Open3D 点云平均点间距评估
Win10调整磁盘存储空间详解
LeetCode 1413.逐步求和得到正数的最小值
x86异常处理与中断机制(3)中断处理过程
API接口是什么?API接口常见的安全问题与安全措施有哪些?
redis缓存如何保证数据一致性
在北京参加UI设计培训到底怎么样?
UNIX Philosophy
[现代控制理论]3_Phase_portrait 相图 相轨迹
How tall is the B+ tree of the MySQL index?
【Robustness of VQA-1】——2019-EMNLP-Don’t Take the Easy Way Out
PTA 换硬币
Use gdb to debug multi-process programs, debug parent and child processes at the same time
PAT1005
VS Code有趣插件