In this example, you will learn to append to a file.
To understand this example, you should have the knowledge of the following Python programming topics:
Open file in append mode and write to it
The content of the file my_file.txt is
honda 1948 mercedes 1926 ford 1903
The source code to write to a file in append mode is:
with open("my_file.txt", "a") as f:
   f.write("new text")
The content of the file after appending a text to it is:
honda 1948 mercedes 1926 ford 1903new text
Open the file in append 'a' mode, and write to it using write() method. Inside write() method, a string "new text" is passed. This text is seen on the file as shown above.
If you want to learn more about different types of file opening modes, please refer to Python file I/O.
Related posts:
Python Numbers, Type Conversion and Mathematics
Python Anonymous / Lambda Function
Python File I/O Operation
Python Program to Compute the Power of a Number
Python String swapcase()
Python Variables, Constants and Literals
Python any()
Python Program to Merge Mails
Python Program to Print all Prime Numbers in an Interval
Python hex()
Python Program to Display Powers of 2 Using Anonymous Function
Python input()
Python Program to Convert Celsius To Fahrenheit
Python Program to Make a Flattened List from Nested List
Python bytes()
Python Program to Convert Decimal to Binary Using Recursion
Python Dictionary setdefault()
Python Program to Find Numbers Divisible by Another Number
Python Program to Make a Simple Calculator
Python round()
How to Get Started With Python?
Python Program to Find the Size (Resolution) of a Image
Python String ljust()
Python Set difference_update()
Python String zfill()
Python open()
Python String index()
Python Program to Check If a String Is a Number (Float)
Python String encode()
Python Program to Find the Sum of Natural Numbers
Python Program to Check If a List is Empty
Python Program to Find Sum of Natural Numbers Using Recursion
 
