总结:虽然他没教给我们很多,但是他已经很棒了 package com.a.b; import java.io.*; public class dd { public static void main(String[] args) throws IOException { File f = new File("C:\\ttee"); if (!f.exists()) { f.mkdir(); } File f2 = new File(f, "yue.txt"); f2
调用os模块,先建立一个对目标目录的walk迭代器. 然后再对迭代器进行遍历,判断每个文件是否以'jpg'结尾. 若是,则输出. import os g = os.walk("G:") for path,d,filelist in g: for filename in filelist: if filename.endswith('jpg'): print (os.path.join(path, filename))