Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function # если python2
- import os
- import re
- words = ('msh', 'mat', 'dds')
- r1 = re.compile(b'[\x20-\x7F]+')
- r2 = re.compile('|'.join(map(re.escape, words)))
- for fname in os.listdir('InputFiles'):
- with open(os.path.join('InputFiles', fname), 'rb') as i:
- with open(os.path.join('OutputFiles', fname), 'w') as o:
- for txt in filter(r2.search, map(bytes.decode, r1.findall(i.read()))):
- print(txt, file=o)
Advertisement
Add Comment
Please, Sign In to add comment