安装:
pip install pyperclip
使用:
import pyperclip
作用:
使用剪贴板复制粘贴字符串
方法:
向剪切板发送文本:copy()
读取剪切板文本:paste()
import pyperclip
import time
import pyautogui
filepath="E:/program/python/test.txt"
pyperclip.copy(filepath)
t=pyperclip.paste()
print(t)
最终输出:“E:/program/python/test.txt”
也直接可以用(ctrl+v)粘贴;
也可以模拟键盘按键:
pyautogui.hotkey("ctrl""v")
pyperclip不可以对文件进行复制粘贴!