开发者

Save image in python 3.1

开发者 https://www.devze.com 2023-01-28 08:06 出处:网络
I have image da开发者_StackOverflow中文版ta in buffer I want to save image in my computer by don\'t use library.

I have image da开发者_StackOverflow中文版ta in buffer I want to save image in my computer by don't use library. (I use python 3.1) Thank you so much.


Okay, in python 3.x the built in open function is aliased to io.open so you can do ( assuming you have image data stored in imagedata)

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()

Now the image will be saved in the local directory with file name image.png.

0

精彩评论

暂无评论...
验证码 换一张
取 消