剪切板訪問工具 ----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()用於將文字從剪切板復制出來