Advertisement
Guest User

Рассортировать файл с ключами

a guest
Nov 10th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # -*- coding: UTF-8 -*-
  2.  
  3. # Путь к txt файлу ключей
  4. # кодировка UTF-8, по оному в строке
  5. key_file_path = r'C:\key.txt'
  6. # Какой ключ искать
  7. key = 'хуй'
  8. # Открываем файл с ключами
  9. keys = open(key_file_path, encoding='utf-8')
  10. # Создаем файл с именем "ключ.txt"
  11. new_key_file = open(key+'.txt', 'w', encoding='utf-8')
  12. # Поиск всех вхождений построчно и запись в файл
  13. for string_from_file in keys:
  14. if key in string_from_file:
  15. new_key_file.write(string_from_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement