Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. from datetime import datetime
  3. match_str1 = "description"
  4. match_str2 = "interface"
  5. with open("config.txt") as f_in:
  6. lines = f_in.readlines()
  7. current_time = datetime.today().strftime("%d.%m.%Y_%H.%M.%S")
  8. with open("textfile1_{}.txt".format(current_time), "w") as f1_out, open("textfile2_{}.txt".format(current_time), "w") as f2_out:
  9. for line in lines:
  10. if match_str1 in line:
  11. f1_out.write(line)
  12. if match_str2 in line:
  13. f2_out.write(line)
  14. print( "\nDone!\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement