Python でファイルの読み込み

published: 2019.04.15 / modified:

Python でファイルの読み込みを行う。

open() でファイルの読み込み

組み込み関数 open() を使用して、ファイルの読み込みを行う。
最初の引数は、ファイル名を指定する。
二つ目の引数(省略可能)は、読み込みの場合、 'r' を指定する。

with open('example.txt', 'r') as f:
    print(f.read())

Previous Article

Next Article