Platform independent tool to copy text to clipboard

前端 未结 3 585
别那么骄傲
别那么骄傲 2021-02-07 11:00

I am trying to write a function that copies a string parameter to the clipboard. I intend to use this in a Python script that I\'ve been working on. This is what I have

相关标签:
3条回答
  • 2021-02-07 11:17

    Yes, there is one for you :)

    Use pyperclip.

    0 讨论(0)
  • 2021-02-07 11:26

    I suppose that you're running on Linux with Gnome.

    That's normal behavior on Gnome, as soon as the source of the copy vanishes e.g. closing the Browser Window you copied from, the clipboard data gets removed too. Workaround is to install the gnome-clipboard-daemon which will preserve the Clipboard state like Windows and KDE do.

    So, there's not much you can do when running under Gnome, besides leaving your script running.

    0 讨论(0)
  • 2021-02-07 11:42

    This worked for me and is very simple. (mac tested only)

    http://www.macdrifter.com/2011/12/python-and-the-mac-clipboard.html

    0 讨论(0)
提交回复
热议问题