Home >>Python File Methods >Python File write() Method
Python File write() Method in python file inserted a specified text depends on the file mode and helps to write a specified text to the file.
Syntax:file.write(byte)
Parameter | Description |
---|---|
byte | Used for inserted a text object |
e= open("file1.txt", "a")
e.write("how are you!")
e.close()
e= open("file1.txt", "r")
print(e.read())
z= open("file2.txt", "a")
z.write("Hello!")
z.close()
z= open("file2.txt", "r")
print(z.read())