用Python将数据复制到剪贴板

By copying the data to the clipboard, we can automate the copying of data from a website or any document.

通过将数据复制到剪贴板 ,我们可以自动从网站或任何文档中复制数据。

pyperclip, provides a cross-platform python module for copying and pasting the text to the clipboard. Pyperclip is a third party library that needs to be installed in the virtual environment or the anaconda environment using the pip.

pyperclip提供了一个跨平台的python模块,用于将文本复制和粘贴到剪贴板 。 Pyperclip是第三方库,需要使用pip安装在虚拟环境或anaconda环境中。

纸夹 (Pyperclip)

Install the pyperclip using pip:

使用pip安装pyperclip: ://pypi.org/project/pyperclip/

To copy the text to the clipboard, pass a string to pyperclip.copy() and to paste the text from the clipboard, invoke pyperclip.paste() and the copied text will be returned as a string value.

要将文本复制到剪贴板 , 请将字符串传递到pyperclip.copy()并从剪贴板粘贴文本 ,然后调用pyperclip.paste() ,复制的文本将作为字符串值返回。

Python code:

Python代码:

#importing the module
import pyperclip

# copies all the data the user has copied
pyperclip.copy(Copy to clipboard)

# paste the copied data from clipboard
pyperclip.paste()

从剪贴板复制数据并将其粘贴的用法 (Usage of copying the data from clipboard and pasting it)

  1. Adding bullet points to wiki markup – get the text from the clipboard, add a star and space to the beginning of each line and then paste the new text to clipboard. 在Wiki标记中添加项目符号点–从剪贴板中获取文本,在每行的开头添加星号和空格,然后将新文本粘贴至剪贴板。
  2. Add a script which retrieves the link from the clipboard, and fetch the metadata for that link, copy the metadata and link back to the clipboard. 添加一个脚本,该脚本从剪贴板中检索链接,并获取该链接的元数据,复制元数据,然后将链接返回至剪贴板。
翻译自:
By copying the data to the clipboard, we can automate the copying of data from a website or any document. 通过将数据复制到剪贴板 ,我们可以自动从网站或任何文档中复制数据。 pyperclip, provides a cross-platform python module for copying and pasting the text to the clipboard. Pyperclip is a third party library that needs to be installed in the virtual environment or the anaconda environment using the pip. pyperclip提供了一个跨平台的python模块,用于将文本复制和粘贴到剪贴板 。 Pyperclip是第三方库,需要使用pip安装在虚拟环境或anaconda环境中。 纸夹 (Pyperclip) Install the pyperclip using pip: 使用pip安装pyperclip: ://pypi.org/project/pyperclip/ To copy the text to the clipboard, pass a string to pyperclip.copy() and to paste the text from the clipboard, invoke pyperclip.paste() and the copied text will be returned as a string value. 要将文本复制到剪贴板 , 请将字符串传递到pyperclip.copy()并从剪贴板粘贴文本 ,然后调用pyperclip.paste() ,复制的文本将作为字符串值返回。 Python code: Python代码: #importing the module import pyperclip # copies all the data the user has copied pyperclip.copy(Copy to clipboard) # paste the copied data from clipboard pyperclip.paste() 从剪贴板复制数据并将其粘贴的用法 (Usage of copying the data from clipboard and pasting it) Adding bullet points to wiki markup – get the text from the clipboard, add a star and space to the beginning of each line and then paste the new text to clipboard. 在Wiki标记中添加项目符号点–从剪贴板中获取文本,在每行的开头添加星号和空格,然后将新文本粘贴至剪贴板。 Add a script which retrieves the link from the clipboard, and fetch the metadata for that link, copy the metadata and link back to the clipboard. 添加一个脚本,该脚本从剪贴板中检索链接,并获取该链接的元数据,复制元数据,然后将链接返回至剪贴板。 翻译自:
经验分享 程序员 微信小程序 职场和发展