我想通过 python 脚本将一些内容存储到剪贴板中。
它基本上只是pyperclip.copy('text')
。
我正在使用 Fedora 21 和 AwesomeWM。我读过here需要剪贴板管理器将其永久存储在剪贴板中。我安装了parcellite
。现在,如果我通过
$python
$>>> import pyperclip
$>>> pyperclip.copy('teststring')
但是如果我在脚本中做完全相同的事情
import pyperclip
pyperclip.copy('teststring')
并使用python filename
执行此脚本。
它不会存储在剪贴板中。
最佳答案
它适用于我的 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 正在运行还是您的脚本比这更复杂?
关于python - 如果脚本退出,Pyperclip 不会持续存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36229737/