1
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.

python3 gzipファイルを読み込みforで回してListに格納する

Posted at
  • 読み込むファイル
    gzip -dc sample.txt.gz
    111
    222
    333
sample.py
import gzip

listaddress = []
with gzip.open("sample.txt.gz", "rt") as f:
    for line in f:
      listaddress.append(line.replace("\n", ""))
print(listaddress)
['111', '222', '333'] #結果
1
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
1
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?