willsonlincake 发表于 2022-4-6 19:14:28

Tkinter自带的剪贴板功能

''' tk_clipboard_action.py
use Tkinter to get access to the clipboard/pasteboard
tested with Python27/33
'''

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()
# keep the window from showing
root.withdraw()

text = "Donnerwetter"
root.clipboard_clear()
# text to clipboard
root.clipboard_append(text)
# text from clipboard
clip_text = root.clipboard_get()

print(clip_text)# --> Donnerwetter
页: [1]
查看完整版本: Tkinter自带的剪贴板功能