From d9464bb1de4ba4c5c5faea82dfb4218457a9a6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= <sornjure@gmail.com> Date: Mon, 18 Mar 2019 06:11:18 +0100 Subject: [PATCH] File --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a4c7b6f..15d2f36 100644 --- a/README.md +++ b/README.md @@ -1070,11 +1070,23 @@ Open * **`'t'` - Text mode (default).** * **`'b'` - Binary mode.** -### Seek +### File ```python -<file>.seek(0) # Move to the start of the file. -<file>.seek(offset) # Move 'offset' chars/bytes from the start. -<file>.seek(offset, <anchor>) # Anchor: 0 start, 1 current pos., 2 end. +<file>.seek(0) # Move to the start of the file. +<file>.seek(offset) # Move 'offset' chars/bytes from the start. +<file>.seek(offset, <anchor>) # Anchor: 0 start, 1 current pos., 2 end. +``` + +```python +<str/bytes> = <file>.read(size=-1) # Reads 'size' chars/bytes or until EOF. +<str/bytes> = <file>.readline() # Returns a line. +<list> = <file>.readlines() # Returns a list of lines. +<str/bytes> = next(<file>) # Returns a line using buffer. Do not mix. +``` + +```python +write(<str/bytes>) # Writes a string or bytes object. +writelines(<list>) # Writes a list of strings or bytes objects. ``` ### Read Text from File