当前位置:网站首页>修改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
边栏推荐
猜你喜欢
元宇宙:下一代互联网启程(附元宇宙深度报告PDF)
数论知识点
UNIX Philosophy
Semaphore SIGCHLD use, how to make the parent that the child performs over, how to make the distinction between multiple child processes. The end
信号量SIGCHLD的使用,如何让父进程得知子进程执行结束,如何让父进程区分多个子进程的结束
Fapi_StatusType Fapi_issueProgrammingCommand使用注意事项
ICML 2022 | Out-of-Distribution Detection with Deep Nearest Neighbors
VS Code有趣插件
win10 outlook邮件设置
x86 Exception Handling and Interrupt Mechanism (1) Overview of the source and handling of interrupts
随机推荐
【概率论】一元概率分布的平均化
PAT1008
PTA 矩阵运算
UNIX Philosophy
Visual Studio 2017 ASP.NET Framework MVC 项目 MySQL 配置连接
ThreadLocal类
PAT 1015 进制转换
MySQL执行sql语句的机制
预置第三方apk到MTK项目相关问题总结
《数字经济全景白皮书》银行业智能营销应用专题分析 发布
【Basic model】Transformer-实现中英翻译
Fapi_StatusType Fapi_issueProgrammingCommand使用注意事项
mysql + redis + flask + flask-sqlalchemy + flask-session 配置及项目打包移植部署
fork创建多个子进程
x86 Exception Handling and Interrupt Mechanism (1) Overview of the source and handling of interrupts
Win10调整磁盘存储空间详解
Oracle Database Architecture
[工程数学]1_特征值与特征向量
Number theory knowledge
MySQL中的锁