Skip to Content
Menú
This question has been flagged
1 Respondre
8426 Vistes

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 Best Answer

I fixed with code:

with open('z.jpg','wb+') as f:
f.write(base64.b64decode(self.file))
Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de febr. 16
4083
0
de maig 20
4567
0
d’oct. 24
5177
1
d’abr. 17
5164