Skip to content

Commit 7daefb3

Browse files
committed
Files functionalities added
1 parent 433a1ca commit 7daefb3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

file.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ‘rt’ will open for read in text mode
88

99

10-
# using open functionn to read content of a while
10+
# Reading file contents
1111
x = open("sample.txt", "r") # we can use single or double inverted comma's here
1212
#open is a built in function
1313
# by default its on "r" and ists not mandatory to mention id you want write or "w" then its mandatory
@@ -24,11 +24,13 @@
2424
print(data)
2525
x.close
2626

27+
# Writing to a file
2728
f = open("writingfile.txt", "w")
2829
f.write("here am writing a file ") # Can be called multiple times
2930
# am writing a file and without a file present at the stage but it will write and save in a new created file
3031
f.close()
3132

33+
# Appending to a file
3234
f = open("writingfile.txt", "a")
3335
f.write("here am appending a file ") # if called multiple times it will append multiple times
3436
f.close()

0 commit comments

Comments
 (0)