python voc文件重命名 ----去除原来文件里面的空格

import os,shutil
num = 0
for file in os.listdir('Annotations2'):
	num +=1
	print(num,file)
	orgin = os.path.join('Annotations2',file)
	target = os.path.join('Annotations','20190618_{:>06d}.xml'.format(num))
	shutil.copy(orgin,target)
	
	orgin = os.path.join('JPEGImages2','{}.jpg'.format(file.split('.')[0]))
	target = os.path.join('JPEGImages','20190618_{:>06d}.jpg'.format(num))
	shutil.copy(orgin,target)

Annotations2待转化的
Annotations转换好的

目录
在这里插入图片描述


版权声明:本文为Fighting_Dreamer原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。