Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
8422 Näkymät

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
Hylkää
Tekijä Paras vastaus

I fixed with code:

with open('z.jpg','wb+') as f:
f.write(base64.b64decode(self.file))
Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
helmik. 16
4082
0
toukok. 20
4567
0
lokak. 24
5177
1
huhtik. 17
5164