import os
import os.path as osp
rootdir = "C:\YSRVOC\VOCdevkit\VOC2007\JPEGImages"
file_object = open('C:\YSRVOC\VOCdevkit\VOC2007\ImageSets\Main/train.txt','w')
for parent,dirnames,filenames in os.walk(rootdir):
for filename in filenames:
filename=filename.partition(".")
print (filename)
file_object.write(filename[0]+ '\n')
file_object.close()
王权富贵:读取指定目录下的所有文件名(不保持后缀)文本处理
猜你喜欢
转载自blog.csdn.net/a1103688841/article/details/84315942
今日推荐
周排行