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)…
典型的递归方法: //定义一个list集合 List<String> list = new List<String>(); public void director(string dirs) { //绑定到指定的文件夹目录 DirectoryInfo dir = new DirectoryInfo(dirs); //检索表示当前目录的文件和子目录 FileSystemInfo[] fsinfos = dir.GetFileSystemInfos(); //遍历检索的文件和子目录 f…
package com.henu.util; import java.io.File; public class TakeFilePathAndName { public static void main(String[] args) { // This is the path where the file's name you want to take. String path = "C://Documents and Settings//yinxm//デスクトップ//TestFile&quo…