简体   繁体   English

<read-write buffer ptr 0x00, size 855 at 0x00>蟒蛇

[英]<read-write buffer ptr 0x00, size 855 at 0x00> python

So i have a piece of code that looks like this: 所以我有一段看起来像这样的代码:

<read-write buffer ptr 0x000000000286AB78, size 855 at 0x000000000286AB40>

I think it should be an image file :) 我认为它应该是一个图像文件:)

I look around and found some links to memoryview but looking at the documentation didn't seem like it would be what im after. 我环顾四周,发现了一些memoryview链接,但看看文档似乎不会是后来的事情。 Of course im rather new to programming. 当然,我对编程很新。

I would like to save the file to a folder so that i could see the picture. 我想将文件保存到文件夹,以便我可以看到图片。 =) =)

Anyone has idea how to solve this? 任何人都知道如何解决这个问题?

you can get access to it with this code, only replace [USERNAME] with your username: 您可以使用此代码访问它,只能将[USERNAME]替换为您的用户名:

import shutil
import os

shutil.copy('C:\Users\[USERNAME]\AppData\Local\Google\Chrome\User Data\Default\Favicons','C:\Users\[USERNAME]\Desktop')
con = sqlite3.connect('C:\Users\[USERNAME]\Desktop\Favicons')
cursor = con.cursor()
icon=''
for i in  cursor.execute("SELECT * FROM favicons WHERE id<6 limit 5;"): 
    icon= i,'favicons'
print('\n')
con.close()
os.remove('C:\Users\[USERNAME]\Desktop\Favicons')

--- ANSWER ---- ---答案----

import StringIO
from PIL import Image
file_ = StringIO.StringIO(icon)
image = Image.open(file_)
size=(128,128)
image=image.resize(size,Image.BILINEAR)
image.save('C:\icon.JPEG', 'JPEG')

Thanks for ideas :) 谢谢你的想法:)

This is not an answer, but hopefully it is better than nothing. 这不是一个答案,但希望它总比没有好。 At least until something better comes around. 至少在更好的事情发生之前。 I think you should take a look at Python Imaging Library (PIL) . 我想你应该看看Python Imaging Library(PIL) You should be able to use: Image.frombuffer(mode, size, data) here's some additional information. 您应该可以使用: Image.frombuffer(mode, size, data) 这里有一些额外的信息。 You can also try Image.open() as I suppose you are getting the image from a sql database? 你也可以尝试Image.open()因为我想你从sql数据库中获取图像?

import StringIO

data = read_from_database()

file = StringIO.StringIO(data)

image = Image.open(file)
image.thumbnail((128, 128))

outfile = StringIO.StringIO()
image.save(outfile, "JPEG")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM