How to Copy Text to the Clipboard in Python
If you need to Copy Text to the Clipboard using your Python application code, then you can do the following:
Option 1 – Using pyperclip
First install the pyperclip
package, using pip
:
|
|
Now you can run the following code:
Option 2 – Using pyperclip3
This version is similar to the first option above, except it copies all the data into bytes
.
Option 3 – Using clipboard
Option 4 – Using xerox
First you will need to install the xerox
package, using pip
:
|
|
Now you can run the following: