gpt4 book ai didi

Python 值错误 : embedded null byte when reading png file from bash pipe

转载 作者:IT王子 更新时间:2023-10-28 23:57:33 26 4
gpt4 key购买 nike

from PIL import Image
from subprocess import Popen, PIPE

scr = Image.open(Popen.communicate(Popen(['import','-w','0x02a00001','png:-'], stdout=PIPE))[0])

错误:

  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2258, in open
fp = builtins.open(filename, "rb")
ValueError: embedded null byte

最佳答案

首先尝试将原始数据加载到 BytesIO 容器中:

from io import BytesIO
from PIL import Image
from subprocess import Popen, PIPE

data = Popen.communicate(Popen(['import','-w','0x02a00001','png:-'], stdout=PIPE))[0]
scr = Image.open(BytesIO(data))

关于Python 值错误 : embedded null byte when reading png file from bash pipe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38979075/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com