Files and Exceptions
Read and write files safely, and handle errors with try/except.
Beginner
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
Exception Handling in Python
Catch and handle errors with try / except / else / finally, and raise your own.
Easy♥ 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.