-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO.py
More file actions
33 lines (22 loc) · 701 Bytes
/
Copy pathIO.py
File metadata and controls
33 lines (22 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# this enables us to file handling
f=open("d.txt",'w')
# text=f.read() # use to read text file and to extract it
# print(text)
# f.close()
# write
# f.write("hello")
# f.close()
# append
# f.write(" i am danish")
# f.close()
# we can also use this - by using with we donot need to close the f
# with open("d.txt",'a'):
# f.write("iside with")
# other methods
# while True:
# a=f.readline() # it will read line by line
# print(a)
# if not a:
# break
# writelines will write line one by one and if the given file is not created then it will creates a new one
#In Python, seek() function is used to change the position of the File Handle to a given specific position