A cross-platform clipboard module for Python. (only handles plain text for now) By Al Sweigart firstname.lastname@example.org BSD License
- import pyperclip pyperclip.copy(‘The text to be copied to the clipboard.’) spam = pyperclip.paste()
On Windows, no additional modules are needed. On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os. On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run “sudo apt-get install xclip” or “sudo apt-get install xsel”
Otherwise on Linux, you will need the gtk or PyQt4 modules installed.
The gtk module is not available for Python 3, and this module does not work with PyGObject yet.