0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonでbase64形式の画像をデコードしてローカルに保存するメモ

Posted at

はじめに

仕事でbase64形式で画像データが返ってくるAPIをローカルに保存するというのがありましたが
少し苦戦したのでメモ(初心者向け)

環境

python 3.7.0

base64の形式

data:image/png;base64,iVBORw0KGg.....

コード

splitString = base64文字列が格納された変数.split(',')
    img_binary = base64.b64decode(splitString[1])
    filename='hoge.png'
    with open(filename, 'wb') as f:
        f.write(img_binary)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?