可以通过以下步骤实现:
import base64
from PIL import Image
from io import BytesIO
def base64_to_image(*base64_strings):
images = [] # 用于存储转换后的图像对象
for base64_string in base64_strings:
image_data = base64.b64decode(base64_string)
image = Image.open(BytesIO(image_data))
images.append(image)
return images
image1_base64 = "..."
image2_base64 = "..."
image3_base64 = "..."
images = base64_to_image(image1_base64, image2_base64, image3_base64)
注意事项:
PIL
库(可使用pip install pillow
命令进行安装)。image1_base64
、image2_base64
、image3_base64
。这是一个在Python中将多个base64转换为图像的简单示例。如果需要更复杂的处理,可以参考相关文档或库的使用说明。
领取专属 10元无门槛券
手把手带您无忧上云