Advertisement
Guest User

Untitled

a guest
Jul 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. NAME:APPLE
  2. IMG:1.PNG
  3. END
  4.  
  5. NAME:PEAR
  6. IMG:1.GIF
  7. END
  8.  
  9. NAME:PEACH
  10. IMG:2.PNG
  11. END
  12.  
  13. NAME:PEACH
  14. IMG:2.PNG
  15. END
  16.  
  17. NAME:APPLE
  18. IMG:1.PNG
  19. END
  20.  
  21. imgTyp="PNG"
  22.  
  23. with open("txt1.txt",'r') as f1, open("txt2.txt",'r') as f2:
  24. f1line=set(f1.read().splitlines())
  25. f2line=set(f2.read().splitlines())
  26.  
  27. for line in f1line:
  28. if imgTyp in line:
  29. with open("txtTemp.txt","a") as fTemp:
  30. fTemp.writelines(**the lines with PNG in txt1 that is missing in txt2, and the line above and under each line**)
  31. **Then merge f2 and fTemp to get txt3.txt**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement