Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 在python 3.1中保存图像_Image_Python 3.x_Save - Fatal编程技术网

Image 在python 3.1中保存图像

Image 在python 3.1中保存图像,image,python-3.x,save,Image,Python 3.x,Save,我的缓冲区中有图像数据,我想通过“不使用库”将图像保存到我的计算机中。 (我使用python 3.1) 非常感谢你 好的,在python 3.x中,内置的open函数被别名为io.open,因此您可以这样做(假设图像数据存储在imagedata) 现在,图像将保存在本地目录中,文件名为image.png好的,在python 3.x中,内置的open函数被别名为io.open,因此您可以这样做(假设图像数据存储在imagedata中) 现在图像将保存在本地目录中,文件名为image.pngpyth

我的缓冲区中有图像数据,我想通过“不使用库”将图像保存到我的计算机中。 (我使用python 3.1)
非常感谢你

好的,在python 3.x中,内置的
open
函数被别名为
io.open
,因此您可以这样做(假设图像数据存储在
imagedata


现在,图像将保存在本地目录中,文件名为
image.png

好的,在python 3.x中,内置的
open
函数被别名为
io.open
,因此您可以这样做(假设图像数据存储在
imagedata
中)


现在图像将保存在本地目录中,文件名为
image.png

python 3.x不支持打开吗??如果是,则
f=open('file','w');f、 写入(imagedate);f、 close()python 3.x不支持打开吗??如果是,则
f=open('file','w');f、 写入(imagedate);f、 close()嗯?在PEP 3116中没有这样的声明。@Lennart:好的,我同意,但检查一下,现在提到新的
io
模块是做i/O的标准方式。PEP 3116imagedate下的是缓冲区类型,不能写这个。然后一个快速而肮脏的方式:用
f.write(imagedate.read())替换
f.write(imagedate)
@Shiv:是的,io是io的新模块。建议您从io导入open。这完全没有意义,因为open已经是io的别名了。open所以来自io的
导入open
什么都不做。嗯?在PEP 3116中没有这样的声明。@Lennart:好的,我同意,但检查一下,现在提到新的
io
模块是做i/O的标准方式。PEP 3116imagedate下的是缓冲区类型,不能写这个。然后一个快速而肮脏的方式:用
f.write(imagedate.read())替换
f.write(imagedate)
@Shiv:是的,io是io的新模块。建议您从io导入open。这完全是毫无意义的,因为open已经是io.open的别名,所以从io导入open的
什么都不做。
filename = "image.png"  # use suitable extension according to the format of the image
f = open(filename, 'w') # first argument is the filename
f.write(imagedate)
f.close()