# -*- coding: utf-8 -*- import os def file_name(file_dir): with open("SelectAllFiles.txt","w") as f: for root, dirs, files in os.walk(file_dir,topdown=True): for name in files: f.write(name+'\n') if __name__=="__main__": file…
1 #获取文件夹内的图片 2 import os 3 def get_imlist(path): 4 return [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')] 5 6 img_path = get_imlist("database") 7 print(img_path)…
查看当前目录下所有py文件(本身除外run) import os file_list = os.listdir(os.getcwd()) # 获取当前目录下所有的文件名print(file_list)for filename in file_list: if os.path.isfile(filename) and filename.endswith('.py') and filename.find("run") == -1: print(filename,'\n') os.syst…