Python訪問剪切板


剪切板訪問工具 ----pyperclip

The purpose of Pyperclip is to provide a cross-platform Python module for copying and pasting text to the clipboard.

pyperclip是用於跨平台的剪切板訪問讀寫工具庫

安裝

$ sudo pip2 install pyperclip

測試使用

>>>import pyperclip
>>>pyperclip.copy("this is a test")
>>>pyperclip.paste()
this is a test

可以先用鼠標選中一部分文字進行復制,然后運行pyperclip.paste(),你會發現輸出的就是你復制的內容.如果先用pyperclip.copy("this is a test"),再用鼠標進行粘貼也會是this is test.

總結來說:

  • pyperclip.copy()用於將文字復制進剪切板
  • pyperclip.paste()用於將文字從剪切板復制出來


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM