How to Write to Text File in Python

PHOTO EMBED

Mon Apr 29 2024 14:14:16 GMT+0000 (Coordinated Universal Time)

Saved by @Rapha9000

lines = ['Readme', 'How to write text files in Python']
with open('readme.txt', 'w') as f:
    for line in lines:
        f.write(line)
        f.write('\n')
Code language: JavaScript (javascript)
content_copyCOPY

https://www.pythontutorial.net/python-basics/python-write-text-file/