Reading and Writing Files in Python

In this course, you’ll learn about reading and writing files in Python. You’ll cover everything from what a file is made up of to which libraries can help you along that way. You’ll also take a look at some basic scenarios of file usage as well as some advanced techniques.

One of the most common tasks that you can do with Python is reading and writing files. Whether it’s writing to a simple text file, reading a complicated server log, or even analyzing raw byte data, all of these situations require reading or writing a file.

By the end of this course, you’ll know:

  • What makes up a file and why that’s important in Python
  • The basics of reading and writing files in Python
  • Some basic scenarios of reading and writing files

This tutorial is mainly for beginner to intermediate Pythonistas, but there are some tips in here that more advanced programmers may appreciate as well.

About Darren Jones

Darren Jones

With 20 years as a teacher of music technology, Darren is keen to bring his skills to the Python table.

» More about Darren

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

Abby Jones on July 10, 2019

Fantastic course!

aradim on July 13, 2019

EXCELLENT COURSE! Thank you

Robert on July 14, 2019

Very nice,

Watching it is helping me to get through an area where I’ve been stuck. I’ll be back to watch several times and type it out, such is my memory ( need an upgrade!).

Thank you,

ALXTheMaster on July 31, 2019

Great course! i like when you keep writing the code again and again, that just makes me better just by watching, by the time i opened pycharm, i was distracted doing something else, but then i challenged myself to write the code by not looking at the video after 35 minutes and guess what, i am a beginner and it got stock in my head. THANK YOU!

michelnakhla on Aug. 25, 2019

Excellent videos with crisp clear explanations.

« Browse All Courses