Skip to content
UPEEC

Files and Exceptions

Read and write files safely, and handle errors with try/except.

Beginner
Comments 0

Programs constantly deal with things that can go wrong: a file is missing, a serial port is busy, a sensor returns garbage. Python's exceptions and the with statement make this manageable.

Sub-topics (2)

File Handling in Python

Open, read and write text and binary files with the with statement.

Beginner♥ 0🔖 0💬 0

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.