import os
class ReadImageName():
def __init__(self):
self.path = r'\Annotations'#图片地址
def readname(self):
filenames = os.listdir(self.path)
flielist = []
for item in filenames:
if item.endswith('.png'):
# itemname = os.path.join(self.path, item)
itemname = item[:-4]
flielist.append(itemname)
fo = open(r"E:\name.txt", "w")#txt地址
for item in flielist:
fo.write(str(item) + "\n")
if __name__ == '__main__':
log = ReadImageName()
log.readname()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)