I am trying to copy the contents of a variable to the clipboard automatically within a python script. So, a variable is created that holds a string, and I'd like to copy that string to the clipboard.
Is there a way to do this with Pyclips or
os.system("echo '' | pbcopy")
Have you tried this?
import os def addToClipBoard(text): command = 'echo ' + text.strip() + '| clip' os.system(command)
Read more solutions here.
You may call it as: