1

我想通过 python 脚本将一些东西存储到剪贴板中。

基本上只是pyperclip.copy('text')。我正在使用带有 AwesomeWM 的 Fedora 21。我在这里读到需要一个剪贴板管理器才能将其永久存储在剪贴板中。我安装了parcellite. 如果我在终端中使用它,它现在可以通过

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

但是如果我在脚本中做同样的事情

import pyperclip
pyperclip.copy('teststring')

并使用python filename.

它不会存储在剪贴板中。

4

1 回答 1

1

它适用于 pyperclip-1.5.27。使用此脚本,test.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 正在运行还是您的脚本比这更复杂?

于 2016-03-25T23:51:02.820 回答