To read a file, we use mode "r" with open().
• read(): reads all the content
• readline(): reads one line at a time
python
# First, create a file to read
with open("readme.txt", "w") as f:
f.write("First line.\nSecond line.")
# Now, read the file
with open("readme.txt", "r") as f:
content = f.read()
print(content)You should see
First line. Second line.