read()

say it: “REED” /ˈrid/

Reads a whole open file into one string.

What does read() do?

read() reads the whole contents of an open file and gives it back as one string.

with open("recipe.txt") as file:
    text = file.read()
print(text)

Level: Apprentice · More Python terms at this level

Updated