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 1 year has passed since last update.

【備忘録】ZipFileのopenメソッドとwritestrメソッド

Last updated at Posted at 2022-05-10

背景

  • ZipFileのopenメソッドを使ったwriteとwritestrメソッドを使った書き込みの確認

考えたこと

コード

import zipfile

content = 'content'

def zip_file_open():
    zipfilename = 'open.zip'
    with zipfile.ZipFile(zipfilename, mode="w") as zip_file:
        with zip_file.open('open.csv', 'w') as f:
            f.write(content.encode())

def zip_file_writestr():
    zipfilename = 'writestr.zip'
    with zipfile.ZipFile(zipfilename, mode="w") as zip_file:
        zip_file.writestr('writestr.csv', content)
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?