Browse Source

Open

pull/10/head
Jure Šorn 6 years ago
parent
commit
7ca352a8f6
1 changed files with 2 additions and 2 deletions
  1. 4
      README.md

4
README.md

@ -854,14 +854,14 @@ while True:
* `'t'` - text mode (default) * `'t'` - text mode (default)
* `'+'` - open a disk file for updating (reading and writing) * `'+'` - open a disk file for updating (reading and writing)
#### Read Text File: #### Read Text from File:
```python ```python
def read_file(filename): def read_file(filename):
with open(filename, encoding='utf-8') as file: with open(filename, encoding='utf-8') as file:
return file.readlines() return file.readlines()
``` ```
#### Write to Text File: #### Write Text to File:
```python ```python
def write_to_file(filename, text): def write_to_file(filename, text):
with open(filename, 'w', encoding='utf-8') as file: with open(filename, 'w', encoding='utf-8') as file:

|||||||
100:0
Loading…
Cancel
Save