Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
8063 Vistas

Hi, Everyone,

I used the code:

with open('z.jpg','wb') as f:
f.write(base64.b64decode(self.file))

the 'file' is the name of Binary field which have put a photo in, but I can't open the file (z.jpg) I have got correctly.

So, Are there anyone can modify this code and make it work?

Avatar
Descartar
Autor Mejor respuesta

I fixed with code:

with open('z.jpg','wb+') as f:
f.write(base64.b64decode(self.file))
Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
feb 16
3651
0
may 20
4035
0
oct 24
4552
1
abr 17
4620