Advertisement
DariaFil

Strings

May 4th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import string
  2.  
  3.  
  4. def strings(filename, min_str_len=4):
  5. set_of_symbols = set([ord(i) for i in string.printable])
  6. with open(filename, 'rb') as file:
  7. for str in file:
  8. result = ''
  9. for sym in str:
  10. if sym in set_of_symbols:
  11. result += chr(sym)
  12. else:
  13. if len(result) > min_str_len:
  14. yield result
  15. result = ''
  16. if len(result) > min_str_len:
  17. yield result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement