import os
path = '/root/Desktop/adaption_s3fd/DarkFace_Train/label'
path_list = os.listdir(path)
path_list.sort()
f = 'f.txt'
a = []
for filename in path_list:
full_path = os.path.join(path, filename)
with open(full_path) as f:
lines = f.readlines()
img= '0--' + filename[:-4] + '.jpg'
print(filename)
print(img)
lines.insert(0, img+'\n')
a.append(lines)
for items in a:
for item in items:
print(item)
f = open('f.txt', 'a')
f.write(item)
f.close()