mirror of
https://github.com/Asabeneh/30-Days-Of-Python.git
synced 2026-06-03 21:02:42 +08:00
Update 19_file_handling.md
This commit is contained in:
parent
b78270feb3
commit
13b5100d7c
@ -166,7 +166,7 @@ with open('./files/reading_file_example.txt') as f:
|
||||
|
||||
To write to an existing file, we must add a mode as parameter to the _open()_ function:
|
||||
|
||||
- "a" - append - will append to the end of the file, if the file does not it creates a new file.
|
||||
- "a" - append - will append to the end of the file, if the file does not exist it creates a new file.
|
||||
- "w" - write - will overwrite any existing content, if the file does not exist it creates.
|
||||
|
||||
Let us append some text to the file we have been reading:
|
||||
@ -349,6 +349,7 @@ with open('./files/csv_example.csv') as f:
|
||||
```sh
|
||||
# output:
|
||||
Column names are :name, country, city, skills
|
||||
Number of lines: 1
|
||||
Asabeneh is a teacher. He lives in Finland, Helsinki.
|
||||
Number of lines: 2
|
||||
```
|
||||
|
||||
Loading…
Reference in New Issue
Block a user