Reading and Writing Files in Python: Summary
In this course, you learned about reading and writing files in Python. You covered everything from what a file is made up of to which libraries can help you along that way. You also took a look at some basic scenarios of file usage as well as some advanced techniques.
You now know what makes up a file and why that’s important in Python, the basics of reading and writing files in Python, and some basic scenarios of reading and writing files.
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:01 Well done, you’ve reached the end of this series on reading and writing files in Python.
00:06 You’ve seen how to open and close files safely with a number of different methods. You’ve seen different methods you can use to read different amounts of data from a file, whether it’s bytes, lines, or the entire file’s contents. You’ve seen how you can write one or more strings to an open file, and also how you can add content to the end of a file.
00:28
You’ve seen the differences in creating paths on Windows and other OSes, and how you can deal with that using Python’s os
module. You’ve seen the difference between line endings on Windows and other OSes.
00:42 And you’ve seen how you can examine the contents of a file in-depth using just a few lines of Python to understand what’s really going on at the lowest level.
00:52 I hope you’ve enjoyed these videos and found them useful and we’ll see you again soon at realpython.com.
aradim on July 13, 2019
EXCELLENT COURSE! Thank you
andersgs on July 14, 2019
Thank you. I learned about bpython and the pattern:
python
if input() == 'x':
break
That will be very useful.
For manipulating paths, however, I do prefer pathlib
(docs.python.org/3/library/pathlib.html). I think the PEP around the rationale for pathlib
is worth a read (www.python.org/dev/peps/pep-0428/).
Thank you again for the great tutorial.
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,
sion on July 26, 2019
Covered the basics and useful extensions of them. Well presented, 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 and clear.
michelnakhla on Nov. 25, 2019
Great course, professionally done.
Victor Amadi on Nov. 29, 2019
Really informative. Thanks Darren.
markthiele on March 19, 2020
Thanks, very useful!
Cristian Palau on April 10, 2020
Thank you!
pshapard on April 12, 2020
Thanks for this course.
Howard M Sherman on April 22, 2020
I’m sort of a newbie to Python, and I believe that this course would be much richer if it gave some more background information to some fundamental topics such as: text vs. binary data; reading files a line at a time vs. reading the whole file into memory at once; unicode data and its utf-8 encoding vs. ascii; etc. Reading and writing files is a fundamental skill for Python or any other programming language, and I just feel this course was a bit short on the background information needed for one who isn’t already experienced in Python to benefit.
Dan Bader RP Team on April 22, 2020
Thanks for your feedback Howard! This course is intended for an intermediate skill level. If you’re looking for an introduction to working with files in Python, I’d like to recommend the following resources:
beingpython on Aug. 29, 2020
Very well done!
Ghani on Nov. 2, 2020
Nice and simple introduction to the subject; thanks a lot!
Eriberto on Nov. 6, 2020
Love the course, good job by the author. Would have been more great if exercise files were added to the resources link. Yeah, I know there is supplementary post related to this like realpython.com/read-write-files-python/#what-is-a-file but the exercises presented can be a good hands on to follow along if exercise files were added. Overall thumbs up to Darren.
scottbeecher on July 30, 2021
Excellent layout; nicely paced.
nickyniu123 on Aug. 27, 2023
Very good course.
Become a Member to join the conversation.
Abby Jones on July 10, 2019
Fantastic course!