File_Handling_Python
File_Handling_Python
Examples:
1. Creating a File
-----------------------
file = open("example.txt", "w")
file.write("Hello, this is a new file!")
file.close()
2. Reading a File
-----------------------
file = open("example.txt", "r")
content = file.read()
print(content)
file.close()
4. Appending to a File
-----------------------
file = open("example.txt", "a")
file.write("\nAdding new content without deleting old data.")
file.close()