0
0

More than 1 year has passed since last update.

Python read(), readline(), readlines()の違い

Posted at

1.read()・・・readメソッドは開いたファイル全体を文字列として取得する。\nは含む

読み込んだファイルで文字数制限を付ける
例:read(5) とすると、読み込んだファイルから5文字読み込む

2.readline()・・・そのまま実行すると、ファイルを1行だけ読み込む。

3.readlines()・・・ファイル全体を行ごとに分割したリストとして取得できる。

参照:https://qiita.com/kaonashikun/items/e670318803748b71f1e9

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