Skip to content

Commit dfca324

Browse files
fileoperation
1 parent 52d62ac commit dfca324

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fileoperation

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
file_name = "example.txt"
2+
with open(file_name, "w") as file:
3+
file.write("Hello, this is a sample file.\n")
4+
5+
6+
with open(file_name, "r") as file:
7+
content = file.read()
8+
print("Content of the file:")
9+
print(content)
10+
11+
12+
with open(file_name, "a") as file:
13+
file.write("This is some additional text.\n")
14+
15+
with open(file_name, "r") as file:
16+
content = file.read()
17+
print("\nUpdated content of the file:")
18+
print(content)

0 commit comments

Comments
 (0)