1import pyperclip
2pyperclip.copy('The text to be copied to the clipboard.')
1# To use native Python directories, use:
2from subprocess import check_call
3
4# On windows use:
5def copy2clip(txt):
6 cmd='echo '+txt.strip()+'|clip'
7 return check_call(cmd, shell=True)
8
9# On Mac use:
10def copy2clip(txt):
11 cmd='echo '+txt.strip()+'|pbcopy'
12 return check_call(cmd, shell=True)
13
14# Then to call the function use:
15copy2clip('This is on my clipboard!')