python替换删除增加图像名称中特定字符

# -*- coding:utf-8 -*-
import os

path = "./3-concreteCrackSegmentationDataset/rgb/"
files = os.listdir(path)

for file in files:
    print(file)

i = 0
for file in files:
    # old name
    old = path + os.sep + files[i]
    # new name
    new = path + os.sep + file.replace('JPG','jpg')
    #new = path + os.sep + 'fcn32s_hr_' + file
    #new = "E:" + os.sep + file[8:]
    os.rename(old,new)
    i+=1

猜你喜欢

转载自blog.csdn.net/weixin_42535423/article/details/121888854