import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')
spam = pyperclip.paste()
from tkinter import Tk
def Copy(txt):
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(str(txt))
r.update() # now it stays on the clipboard after the window is closed
r.destroy()
Copy("It Works")