1# Program to write multiple lines to text file using writelines() function
2with open("python.txt", "w") as file:
3 content = ["Hello\n", "Welcome to Python Tutorial\n", "Cheers \n" ]
4 file.writelines(content)
5 file.close()
6
7# Program to read the entire file (absolute path) using read() function
8with open("C:/Projects/Tryouts/python.txt", "r") as file:
9 content = file.read()
10 print(content)
11 file.close()