Advertisement
steve-shambles-2109

189-Paste until exit

Oct 23rd, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. """
  2. Python code snippets vol 38:
  3. 189-Paste until exit
  4. stevepython.wordpress.com
  5.  
  6. requirements: pip3 install pyperclip
  7.  
  8. source:
  9. https://gist.github.com/klevyr/60655d9d3e4aff3d127055909188238b
  10. """
  11.  
  12. import pyperclip as clipbd
  13. # Capture the information from your clipboard and paste them into a
  14. # file until the text "EXIT!" Is copied.
  15.  
  16. lastdata = ""
  17. f = open("Product.txt", "a+")
  18.  
  19. while clipbd.paste() != 'EXIT!':
  20.     if lastdata == clipbd.paste():
  21.         continue
  22.  
  23.     else:
  24.         lastdata = clipbd.paste()
  25.         print(lastdata)
  26.         i = 0
  27.         for line in lastdata.split(sep="\r\n"):
  28.             i = i + 1
  29.             if i >= 8 and i < 22:
  30.                 f.write("{}\n".format(line.strip()))
  31.  
  32. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement