I want to copy text with newlines to the clipboard using the following code.
import pyperclip
numbers=''
for i in range(200):
    numbers = numbers + str(i) + '\n'
pyperclip.copy(numbers)
After execution the clipboard should contain:
0
1
2
.
.
200
But after I run the program and paste in Notepad. I see
012345....200
All in a single line. :( I use Python 3.6.1 on Windows 10
I assume you're pasting into microsoft notepad. In this case you should use \r\n (windows style) instead of \n only (unix style)
If you paste into notepad++ it will treat the newline character unix style, and you will see it separated like you want.
If you want to be OS independent then use os.linesep
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With