美文网首页
Python:剪切板的读取&写入

Python:剪切板的读取&写入

作者: R_zb | 来源:发表于2021-02-11 00:01 被阅读0次

前期准备

使用演示

  • 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

相关文章

网友评论

      本文标题:Python:剪切板的读取&写入

      本文链接:https://www.haomeiwen.com/subject/hjlcxltx.html