import os
file_path = "数据路径"
path_list = os.listdir(file_path)
path_name = []
for i in path_list:
path_name.append(i.split(".")[0])
for file_name in path_name:
with open("dataset.txt", "a") as file:
file.write(file_name + "\n")
print(file_name)
file.close()
【Python】提取图片文件名并写入txt中
于 2022-05-15 00:10:58 首次发布