如果脚本退出,Pyperclip不会持久化

2024-04-19 10:22:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我想通过python脚本将一些内容存储到剪贴板中。你知道吗

基本上就是pyperclip.copy('text')。 我在用Fedora 21和AwesomeWM。我读到here需要一个剪贴板管理器将其永久存储在剪贴板中。我安装了parcellite。如果我把它用在终端上,它现在可以工作了

$python
$>>> import pyperclip
$>>> pyperclip.copy('teststring')

但如果我在剧本里做同样的事

import pyperclip
pyperclip.copy('teststring')

并用python filename执行这个脚本。你知道吗

它不会存储在剪贴板中。你知道吗


Tags: textimport脚本终端内容管理器herecopy
1条回答
网友
1楼 · 发布于 2024-04-19 10:22:45

它适用于我的pyperclip-1.5.27。有了这个剧本,测试.py地址:

import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')

$>python ./test.py

然后执行Ctrl+V粘贴:

The text to be copied to the clipboard.

你确定吗pyperclip.copy文件是在运行还是你的脚本比这更复杂?你知道吗

相关问题 更多 >