
获得徽章 0
- 今天中午在园区散步,遇到一对情侣。男的在笑脸哄着女的,女的一副生气的样子,脸色超级差。男的一直笑脸相迎,至少走了很长一段时间。从女的脸色,能看出厌恶的神情,说话声音很冲,男的一边笑着脸哄着,女的一点不为所动,脸色还是非常差。
不知为何看到这一幕,看到了以前的自己,心中不禁笑起来。14 - 分享一下今天撸的:
遍历文件夹,获取文件夹以及子文件夹的全部图片:
def findImg(source_dir):
img_list = []
img_formats = ['jpeg','jpg','png','gif','webp']
file_formats = ['psd']
for child_name in os.listdir(source_dir):
child_file = os.path.join(source_dir,child_name)
if os.path.isdir(child_file):
if child_name[0] != '_':
img_list += findImg(child_file)
elif os.path.isfile(child_file):
if child_name[0] != '.':
img_item = {'absoult_path':child_file}
child_name_ends = child_name.split('.')[-1]
if child_name_ends in img_formats:
img_item['file_type'] = 'img'
img_list.append(img_item)
elif child_name_ends in file_formats:
img_item['file_type'] = 'file'
img_list.append(img_item)
else:
pass
return img_list展开评论1