根据下面的内容我们可以发现:
sudo apt-get install xsel xclip
Introduction
Purpose
The purpose of Pyperclip is to provide a cross-platform Python module for copying and pasting text to the clipboard.
To copy text to the clipboard, pass a string to pyperclip.copy(). To paste the text from the clipboard, call pyperclip.paste() and the text will be returned as a string value.
>>> import pyperclip
>>> pyperclip.copy('Hello world!')
>>> pyperclip.paste()
'Hello world!'
Not Implemented Error
You may get an error message that says: “Pyperclip could not find a copy/paste mechanism for your system. Please see https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error for how to fix this.”
In order to work equally well on Windows, Mac, and Linux, Pyperclip uses various mechanisms to do this. Currently, this error should only appear on Linux (not Windows or Mac). You can fix this by installing one of the copy/paste mechanisms:
sudo apt-get install xselto install the xsel utility.sudo apt-get install xclipto install the xclip utility.pip install gtkto install the gtk Python module.pip install PyQt4to install the PyQt4 Python module.
Example Usage
>>> import pyperclip
>>> pyperclip.copy('The text to be copied to the clipboard.')
>>> pyperclip.paste()
'The text to be copied to the clipboard.'
Currently only handles plaintext.
On Windows, no additional modules are needed.
On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.
On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run "sudo apt-get install xclip" or "sudo apt-get install xsel" (Note: xsel does not always seem to work.)
Otherwise on Linux, you will need the gtk or PyQt4 modules installed.
本文介绍了一个Python模块Pyperclip,它可以在Windows、Mac和Linux等不同平台上实现文本的复制与粘贴功能。文章提供了使用示例,并针对Linux环境下可能出现的NotImplementedError错误给出了详细的解决方案。

1232

被折叠的 条评论
为什么被折叠?



