Skip to content
UPEEC

open()

Opens a file and returns a file object; always use it with `with`.

Beginner
Comments 0
with open("data.csv", encoding="utf-8") as f:
    rows = f.readlines()

Modes: r, w, a, x, add b for binary and + for read/write.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.