# 引入模块
import os
###################################################
f = open("/home/lqs/Documents/arcface-pytorch-master/data/error.txt", "r")
lines = f.readlines() # 读取全部内容
for line in lines:
isExists = os.path.exists(line)
# 拆分字符串
line_array = line.split('\t')
first_col = line_array[0] # 分割出待创建文件夹名称
s = first_col.replace('\n', '')
#print(s)
os.remove(s)
print("Delete File: " + s)
结果:
Delete File: /home/lqs/Documents/arcface-pytorch-master/data/902_Pic_Fea/Leijingsi/16.jpg
Delete File: /home/lqs/Documents/arcface-pytorch-master/data/902_Pic_Fea/Guyingchen/16.jpg