How to write to a file? | Python

/ #Python

In this guide, I will show you how easy it is to store information in files using Python.

# First set a variable with information
the_text = 'This information will be stored in a file'

the_file = open('the_file.txt', 'w') 

If you run this. A new file called "the_file.txt" should be created with the contents from the "the_text" variable.


No comments yet...

Add comment


Subscribe to my weekly newsletter. One time per week I will send you a short summary of the tutorials I have posted in the past week.