Python script to copy text to clipboard

iamsiva11 picture iamsiva11 · Jun 16, 2012 · Viewed 216.5k times · Source

I just need a python script that copies text to the clipboard.

After the script gets executed i need the output of the text to be pasted to another source. Is it possible to write a python script that does this job?

Answer

robert picture robert · Jun 16, 2012

See Pyperclip. Example (taken from Pyperclip site):

import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')
spam = pyperclip.paste()

Also, see Xerox. But it appears to have more dependencies.