To copy text to the clipboard in Python, use the pyperclip module.
Before you can use the module, you need to install it with:
pip install pyperclip
Then you can use its copy() method to copy text to the clipboard by:
import pyperclip s1 = "Hello world" pyperclip.copy(s1) s2 = pyperclip.paste() print(s2)
Thanks for reading. I hope you found what you were looking for.
How to Write to a File in Python
About the Author
- I'm an entrepreneur and a blogger from Finland. My goal is to make coding and tech easier for you with comprehensive guides and reviews.
- Artificial Intelligence2023.03.14Best AI Tools of 2023 (Save Time & Boost Productivity)