In Python, you can read and write files. The open() function is used for this. Using the with statement is best, since it closes the file automatically for you.
• "r": Read
• "w": Write
• "a": Append
python
with open("myfile.txt", "w") as f:
f.write("Hello, this is a new file.\n")
f.write("This is the second line.")
print("File 'myfile.txt' has been created.")You should see
File 'myfile.txt' has been created.