我正在进行一个项目,通过套接字从远程计算机接收图像。由于我不知道图像的大小,我正在逐块接收图像,并保存到io.BytesIO()
def imgdisplayer():
nonlocal conn, display
with io.BytesIO() as f:
while True:
bytes = conn.recv(1024)
if not bytes: break
f.write(bytes)
imgobj = pickle.loads(f)
但是我的代码不起作用,我想我对io.BytesIO
的理解有误
这里出现的错误是:
TypeError: a bytes-like object is required, not '_io.BytesIO'
有没有人能帮我解决这个问题,或者建议其他方法来做这个过程
BytesIO
是一个类似文件的对象。如果需要getvalue()
方法的值,则应使用该方法:相关问题 更多 >
编程相关推荐