Text Files in Python || Python Tutorial || Learn Python Programming

Reading and writing text files is an essential programming skill. Python gives you a simple and powerful tool for working with text files: the open function. This lets you open a wide variety of files – both text or binary – in many different modes (read, write and append). Today we will show you how to read and write text files, and show you several ways to accomplish each task.

We’d like to recognize our VIP Patrons who sponsored this video on Patreon! Our sincere thanks to Birds Eat Bees, Andrew Mengede, Markie Waid, and Carlos Araujo. Your generous donation helps make these videos happen!

To learn Python, you can watch our playlist from the beginning: https://www.youtube.com/watch?v=bY6m6_IIN94&list=PLi01XoE8jYohWFPpC17Z-wWhPOSuh8Er-

To​ ​help​ ​us​ continue making videos,​ ​you​ ​can​ ​support​ Socratica at:

​Patreon​: https://www.patreon.com/socratica

Socratica Paypal: https://www.paypal.me/socratica

We also accept Bitcoin! 🙂
Our​ ​address​ ​is: 1EttYyGwJmpy9bLY2UcmEqMJuBfaZ1HdG9

Thank​ ​you!!

If you’d like a reference book, we recommend “Python Cookbook, 3rd Edition” from O’Reilly:

The Mythical Man Month – Essays on Software Engineering & Project Management

You​ ​can​ ​also​ ​follow​ ​Socratica​ ​on:
-​ ​Twitter:​ ​@socratica
-​ ​Instagram:​ ​@SocraticaStudios
-​ ​Facebook:​ ​@SocraticaStudios

Python instructor: Ulka Simone Mohanty (@ulkam on Twitter)
Written & Produced by Michael Harrison (@mlh496 on Twitter)


Intellectual Tux says:

A Python-Kivy series would really be of great help!

Julio Bedaque says:

thank you about this amazin job.

Sai Krishna Pavan Suryatej Meda says:

Could you make a video on GUI making in python

Rose Simon says:

watched almost 30 vedis.it made me to fall in love with learning python..great work…keep it up

Niels Baltodano says:

thank you very much Socratica

Amrit Gupta says:

Hello socratica …how can i download this particular editor…thanx for videos.

codecaine says:

Binary files should be next. 🙂

Max Qin says:

Thanks for the updates. But anyone can further explain the “with open() as obj”, which is confused for me?

kirby urner says:

I’m a fan of the Socratica Python videos. Pithy / Pythonic.

xhimiz14 says:

Great as always

Handsome_Hero says:

i love it. i have to watch 10 times though because she speaks so quickly

igor Smirnov says:

Is it possible to subcribe to only playlist about python, not to the whole chanel?

DevLogger says:

wow you can exit in vim? finally!

Filip Ve says:

XML combines the efficiency of text files with the readability of binary files

Thomas O'Hare says:

Got the email Dec. 1 and here without delay. This is the best IS related video series I have seen in over 20 years of quality time with my square headed girlfriend. Short, sweet and to the point — just like the presenter. 😉

50PullUps says:


George Hatoutsidis says:

Amazing. love your videos

Austin Anderson says:

Episode on binary files would be amazing…

George Miller says:

These videos are so good and so funny

Mithras Kuipers says:

This series is amazing! Please keep up the good work.
The futuristic atmosphere created in this series makes learning code much more fun!
Thank you Socratica team 🙂

Sky Se7en says:

thanks, this is wonderful!

Andy Dyrcz says:

Nice! I’m glad you went into handling exceptions and didnt just leave it showing how to open and read a file.

MurderfaceWill says:

You are hot.

Greg F says:


abdulfattah tawil says:


Yiannos Christou says:

Excellent! Thank you! Please make one about sockets! Thumbs up so it can be seen, should anyone else be interested as well.

CannabinatedFantasy says:

This draws me in enough to want to learn.

Tony Perrone says:

Awesome as always!!

Nanduri Bharrath says:

just like you did, but what if i want to do such analysis for 10-15 .txt documents?
is there a way that i can create a function and pass .txt file as an argument to it?

Dennis Kamonde says:

Thanks Socratics, make more videos about classes

Gao Channing says:


Bruno Araujo says:

Estamos esperando o Socratica no Brasil!!!!!

This could be your advertisement! says:

Can you please make a video on binary files too?

Lúcia Abreu says:

Amazing! I Will share and support 🙂

Albert Farewege says:

great script. great delivery. tks. Loved the final closing comment.


I had asked many times before. Are you gonna do videos C#.Net ?

unvrknow22 says:

I’m a simple man. I see a new Python video from Socratica and I click thumbs up.

kevin madrigales says:

¿cuando subirán video en socratica español?

Tshiamo Phamotse says:

Thanks Socratica as soon as am able I’ll donate to your page.

munna Munna says:

It is very helpful to start with OOPS also..

Michael Schmitt says:

Give me your orders, Socratica.

gespilk says:

Why it is so complicated?
It should be
show me guido_bio.txt

Bruno Araujo says:

Estamos esperando o Socratica no Brasil!!!!!

Neno jay says:

i love these short python videos so much , but that lady in the videos scary the shite out of me.

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!