1.文件夹下所有文件(遍历所有子文件夹):
#-*- coding:utf8-*-
import glob
import os
path=r"D:\project\springdemo"
os.chdir(path)
filedir=glob.glob("**\*.java",recursive=True) #glob.iglob用也一样
for i in filedir:
print(i)
2 .文件夹下某种类型文件
#-*- coding:utf8-*-
import javalang
import glob
path=r"D:\project\springdemo\src\main\java\com\ppdai\dds\cc\service\cyceledependency\*.java"
for filename in glob.glob(path):
print(filename)