Home >>Python File Methods >Python File writelines() Method
Python File writelines() Method is an inbuilt method in python, it is used to writes a sequence of strings to the file where, you can inserted text depends on the file mode stream position and there is no return value.
Syntax:file.writelines(list)
Parameter | Description |
---|---|
list | Used to inserted a list of a text object. |
e = open("file3.txt", "a")
e.writelines(["Hello!", "Welcome to my World."])
e.close()
e = open("file3.txt", "r")
print(e.read())
j = open("file4.txt", "a")
j.writelines(["Hello!", "Welcome to phptpoint."])
j.close()
j = open("file4.txt", "r")
print(j.read())