eolas/neuron/84bce166-ed13-454f-aa4b-b278e38fda7b/Appending_to_files_in_Python.md

19 lines
331 B
Markdown
Raw Normal View History

2024-12-09 18:34:15 +00:00
---
tags: [python, file-system, procedural]
created: Friday, October 25, 2024
---
# Appending to files in Python
```py
file = open("example.txt", "a")
file.write('Add something to the end of the file')
file.close()
```
```py
with open("example.txt", "a"):
file.write("Add something to the end of the file")
file.close()
```