返回指定文件夹下所有图片(.png)的路径
import os
def file_name(file_dir):
L=[]
for root, dirs, files in os.walk(file_dir):
for file in files:
if os.path.splitext(file)[1] == '.png':
L.append(os.path.join(root, file))
return L
#其中os.path.splitext()函数将路径拆分为文件名+扩展名