简体   繁体   中英

clipboard history using python

I am tying to access the clipboard contents using python. I am using the below python script to perform the action.

from tkinter import Tk
r = Tk()
result = r.selection_get(selection="CLIPBOARD")
print(result)

The above snippet helps in fetching the contents that are available in the clipboard currently. My requirement is to fetch the clipboard history completely.

Any suggestions regarding this will be really helpful.

Use the external module called pyperclip

import pyperclip
pyperclip.copy("abc")  # now the clipboard content will be string "abc"
text = pyperclip.paste()  # text will have the content of clipboard

Documentation | Github

pyperclip非常适合从剪贴板复制和粘贴到剪贴板。

import pyperclip result = pyperclip.paste() print(result)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM