首先,关于SO copy image to clipboard in python的问题会得到Write image to Windows clipboard in python with PIL and win32clipboard?的答案,这只适用于Python2.x.——我试过了,但没用。我克服了一个问题:StringIO and cStringIO modules are gone in Python 3.0:,但又遇到了另一个问题:
TypeError: string argument expected, got 'bytes'
因此,对于Python3再次提出同样的问题——如何在Python3中将图像复制到剪贴板?以下是我目前掌握的代码:
^{pr2}$谢谢
你不想在这里}类对象(}。在
StringIO
。图像是原始的二进制数据,在Py3中,str
纯粹用于文本,bytes
和{bytearray
,连续的memoryview
s,mmap
s)用于二进制数据。要将Py2的StringIO.StringIO
替换为二进制数据,您需要在python3中使用io.BytesIO
,而不是{相关问题 更多 >
编程相关推荐