EDElasticDomain

python snippet

Write a text file

Create or overwrite a UTF-8 file with a newline.

from pathlib import Path
path = Path("data/output.txt")
# Overwrite existing content
path.write_text("Hello, world!\n", encoding="utf-8")
# Append instead of overwrite
with path.open("a", encoding="utf-8") as fh:
fh.write("Another line\n")