写一个扫描文件夹的函数scan_files,去扫描imgtest(以上是文件夹的压缩包)文件夹,将其中的后缀为.jpeg的文件打印出来
import os
p= r"C:\Users\86188\Desktop\img\imgtest"
def scan_files(p):
files = os.listdir(p)
for f in files:
ads_f=p+os.sep+f
if os.path.isfile(ads_f) and ads_f.endswith(".jpeg"):
print(ads_f)
elif os.path.islink(ads_f):
print(ads_f)
elif os.path.isdir(ads_f):
scan_files(ads_f)
scan_files(p)