Reading and Writing Files in Python

Darren Jones

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.

What’s Included:

Related Learning Paths:

About 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

Avatar image for scottbeecher

scottbeecher on July 30, 2021

Excellent layout; nicely paced.

Avatar image for Victor Amadi

Victor Amadi on Nov. 29, 2019

Really informative. Thanks Darren.

Avatar image for michelnakhla

michelnakhla on Nov. 25, 2019

Great course, professionally done.

Avatar image for michelnakhla

michelnakhla on Aug. 25, 2019

Excellent videos with crisp clear explanations.

Avatar image for ALXTheMaster

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!

Avatar image for Robert

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,

Avatar image for aradim

aradim on July 13, 2019


Avatar image for Abby Jones

Abby Jones on July 10, 2019

Fantastic course!

« Browse All Courses