Writing Files
write, writelines
Interview Relevant: File output
Writing Files
Code Examples
python
1with open("out.txt", "w") as f:
2 f.write("Hello\n")
3 f.writelines(["Line 1\n", "Line 2"])write, writelines
1with open("out.txt", "w") as f:
2 f.write("Hello\n")
3 f.writelines(["Line 1\n", "Line 2"])Ask about the topic