forked from seven-liu/python_study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.py
More file actions
25 lines (20 loc) · 715 Bytes
/
a.py
File metadata and controls
25 lines (20 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os.path as osp
def yield_filenames(path,ignore_hide_file=True, ignore_prefix=(), ignore_suffix=()):
"""other params may be useful in future"""
path = osp.expanduser(path)
path = osp.abspath(path)
if not path or not osp.isdir(path):
return
for root, dirs, fnames in os.walk(path):
for f in fnames:
if ignore_hide_file and f.startswith('.'):
continue
if f.endswith(ignore_suffix):
continue
if f.startswith(ignore_prefix):
continue
yield osp.join(root, f)
dir='d:\\test'
list1=[]
list1=yield_filenames(dir)
print list1