Hey guys, in this blog we will see a Python Program to Append to a File.
The content of the file
Machine Learning Projects Deep Learning Projects Flask Projects
Open the file in append mode and write to it
with open("my_file.txt", "a") as f: f.write("CV Projects")
Machine Learning Projects Deep Learning Projects Flask ProjectsCV Projects
- Simply open the file in ‘a’ mode which stands for append mode.
- Now write anything that you want to add to the file.
- We have added ‘CV Projects’ and it got added directly after ‘Flask Projects’.
- If you want to add items in the next line you do something like the following:
with open("my_file.txt", "a") as f: f.write("\nCV Projects")
Check out our other python programming examples…