python 模块 pyperclip 操作剪切板

python pyperclip 模块可实现操作剪切板,下面的示例实现获取当前剪切板内容,在获取到的内容前添加“hello:”后再复制到剪切板:

import pyperclip

# 获取剪切板内容到 last_string
last_string = pyperclip.paste()
if last_string:
    # 将 'hello:' + last_string 复制到剪切板
    pyperclip.copy('hello:' + last_string)
posted @ 2020-04-18 11:34  Higurashi-kagome  阅读(972)  评论(0编辑  收藏  举报