Transfer the value of a variable to Ctrl+C in Python?

Asked

Viewed 260 times

-1

I’m doing a job and need the value of a variable to go to the Clipboard so I can use it at another time.

You can do this in Python v2.7?

1 answer

3


You can use that ready lib, like the:

Supports Windows, Mac and Linux (Linux requires gtk or Pyqt4)

Installing via PIP the pyperclip:

pip install pyperclip

Example of use:

import pyperclip


variavel = "Python"

pyperclip.copy(variavel)

Note: internally the https://pypi.org/project/clipboard/ uses pyperclip, so I removed from the answer, there is no advantage in its use, the only reason the author created the lib was to have a "better name" (maybe he does not know how the import works)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.