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 3 years have passed since last update.

Python: 配列の中身をファイルに保存・読み込み

Last updated at Posted at 2021-02-08

ファイル保存

pickleモジュールを利用して配列の中身をファイルに保存します。

>>> import pickle
>>> a = [1,2,3]
>>> f1 = open("aaa", "wb")
>>> pickle.dump(a, f1)
>>> f1.close()

ファイル読み込み

保存したデータを配列として読み込みます。

>>> f2 = open("aaa", "rb")
>>> b = pickle.load(f2)
>>> b
[1, 2, 3]
>>> f2.close()
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?