我正在尝试用我在Python脚本中处理的输出结果覆盖命令Copy - Ctrl+C。
例如。我的脚本输出结果返回this-is-a-test,如果我运行paste (Ctrl+V),它应该粘贴this-is-a-test
这在Python上下文和linux环境中是可以实现的吗?
发布于 2017-01-17 08:43:44
你可以使用pyperclip library,它是跨平台的,应该可以在windows/linux/mac上工作。
>>> import pyperclip
>>> pyperclip.copy('The text to be copied to the clipboard.')
>>> pyperclip.paste()
'The text to be copied to the clipboard.'如果你不能安装任何库,你可以检查代码(on github)并使用它的一部分。它可能会给你你正在寻找的解决方案。
https://stackoverflow.com/questions/41687144
复制相似问题