extrn

Untitled

Mar 16th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. from __future__ import print_function # если python2
  2. import os
  3. import re
  4.  
  5. words = ('msh', 'mat', 'dds')
  6.  
  7. r1 = re.compile(b'[\x20-\x7F]+')
  8. r2 = re.compile('|'.join(map(re.escape, words)))
  9.  
  10. for fname in os.listdir('InputFiles'):
  11.     with open(os.path.join('InputFiles', fname), 'rb') as i:
  12.         with open(os.path.join('OutputFiles', fname), 'w') as o:
  13.             for txt in filter(r2.search, map(bytes.decode, r1.findall(i.read()))):
  14.                 print(txt, file=o)
Advertisement
Add Comment
Please, Sign In to add comment