AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
The file name of the newly created text file will be, “this_is_file.txt” If you run this file it will create a text file in the same directory where this file (the file you have run) is located. Create a text file in PythonĪ single line of code is enough to create a text file: my_file = open("this_is_file.txt","w+") ![]() So I hope you have understood that we are not going to import anything in order to create text files in Python, instead of that we will use a built-in object of python. These functions are open() and write(). With the help of these two functions, we can easily learn how to create a text file in Python and also learn how to add some text to it. To create a text file and to add some text in it we will need to use two inbuilt functions of Python. ![]() ![]() ![]() To create a text file in Python you will need to work with file object of Python.
0 Comments
Read More
Leave a Reply. |