前期准备
- 安装第三方库:pyperclip
使用演示
- pyperclip有2个方法copy() + paste()
- copy():将字符串写入剪切板,可在pc上直接粘贴使用,可至直接只用paste()方法读取
- paste():读取剪切板内容
import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')
pyperclip.paste() # 'The text to be copied to the clipboard.'
print(f"我是复制的内容:{pyperclip.paste()}")
我是复制的内容:The text to be copied to the clipboard.
进程已结束,退出代码 0
本文介绍了pyperclip库的基本使用方法,包括如何通过copy()方法将文本写入剪切板以及如何通过paste()方法从剪切板读取文本。
4845

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



