Continuation of http://qiita.com/items/a8a46173c53830f7d465
>>> fa = ["a", "b", None, "c", "e", None, None, None, "d"]
>>> [i for i in fa if i]
['a', 'b', 'c', 'e', 'd']
>>> #Under the working directory`.eml`Get a list of files with the extension
>>> for root, dirs, files in os.walk(os.path.abspath(".")):
... buff += [os.path.join(root, fname) for fname in files if os.path.splitext(os.path.join(root,fname))[1] == '.eml']
...
>>> buff
['/path/to/1.eml', '/path/to/2.eml']
Recommended Posts