python学习——查找计算机中的文件
# import os
#
# path = 'C:/Users/admin/Desktop/images'
# files = os.listdir(path)
#
# for f in files:
# if 'test' in f and f.endswith('.png'):
# print("文件名匹配:" + f)
# else:
# print('不匹配')
import os
files = 'C:/Users/admin/Desktop/images'
path = os.listdir(files)
for f in path:
if (f.endswith('.jpg')) and ('test' in f or '11' in f):
print('存在文件' + f)
elif 'aaa' in f:
print('存在AAA文件')
elif f.endswith('jpg'):
print('存在IMG文件' + f)
else:
print('不存在特征')
本文来自博客园,作者:知冰,转载请注明原文链接:https://www.cnblogs.com/zhibing/p/16893816.html