This commit is contained in:
Torsten 2025-04-12 14:08:46 +02:00
parent 820737bc69
commit 9d3b7827eb
4 changed files with 152 additions and 1 deletions

View file

@ -0,0 +1,15 @@
```python
lines = ["Line 1\n", "Line 2\n", "Line 3\n"]
with open('output.txt', 'w') as f:
f.writelines(lines) # Writes all lines at once [1][3]
# Alternative with join()
with open('output.txt', 'w') as f:
f.write('\n'.join(lines)) # Joins with newlines automatically [1][4]
```