Python program to create and write to a Text File

Опубликовано: 27 August 2026
на канале: The Programming Portal
49,584
518

In this video, you will learn how to create and write to a Text File using python.
You will learn how to create a new text file, write some data and save the file on local machine.

source code : https://theprogrammingportal.com/Pyth...
GIT : https://github.com/TheProgrammingPort...

Modes in Python : https://docs.python.org/3.6/library/f...

Steps:

1. Open text file using the open() function in the write mode.
2. if file doesn't exist, it will create new file at location
3. write data with python built function write method
4. close the file instance

In this video you will learn:
how to open text file in python
writing to a text file using python
closing the file instance
File Handling in python
Open() method in Python
write() function in python

Want to learn more from me?

Python examples complete Playlist :
   • python program for string palindrome  
Java examples complete Playlist :
   • Java Factorial Program  

#PythonTutorial
#PythonTutorialForBeginners
#PythonProgramToCountWords
#FileHandingInPython
#PythonExamples
#CreatingATextFileInPython

Subscribe to my other channel for random videos:
IndianBox :    / @indianbox1736  

Follow us on:
Facebook :   / theprogrammingportal  
Instagram :   / theprogrammingportal  
Support:
Patreon :   / theprogrammingportal  

Keep Coding!