遍历两个路径的所有图片,并将两个路径的所有图片名称合并成一个数组里面,得出两个路径拥有哪些图片
#!/usr/local/python2.7/bin/python2.7
# -*- coding: utf-8 -*-
import os
for root, dirs, files in os.walk(path1):
for file in files:
if file.endswith('jpg') or file.endswith('jpeg') or file.endswith('gif') or file.endswith('png') or file.endswith('bmp'):
alist2.append(file)
for root, dirs, files in os.walk(path2):
for file in files:
if file.endswith('jpg') or file.endswith('jpeg') or file.endswith('gif') or file.endswith('png') or file.endswith('bmp'):
alist3.append(file)
alist2.extend(alist3)