0
点赞
收藏
分享

微信扫一扫

python实现文件后缀名批量转换

Soy丶sauce 2022-02-04 阅读 80
import os

root_dir = 'dataset/train'
target_dir = 'bees_image'
img_path = os.listdir(os.path.join(root_dir, target_dir))
label = target_dir.split('_')[0]
out_dir = 'bees_label'
for i in img_path:
    file_name = i.split('.jpg')[0]
    with open(os.path.join(root_dir, out_dir, "{}.txt".format(file_name)), 'w') as f:
        f.write(label)

举报

相关推荐

0 条评论