0 0.585938 0.534375 0.350000 0.056250
将类别0修改为2
脚本直接放在标签目录下,cmd窗口的运行
python run.py
run.py
import os
import re
# 路径
# path = r'D:\BUFFER\Pycharm\DectVIN\VINImages\Test/'
# 文件列表
path = './'
files = []
for file in os.listdir(path):
if file.endswith(".txt"):
files.append(path+file)
# 逐文件读取-修改-重写
for file in files:
with open(file, 'r') as f:
new_data = re.sub('^0', '2', f.read(), flags=re.MULTILINE) # 将列中的0替换为2
with open(file, 'w') as f:
f.write(new_data)