-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.py
More file actions
36 lines (24 loc) · 848 Bytes
/
file.py
File metadata and controls
36 lines (24 loc) · 848 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
33
34
35
36
with open('example.txt','r') as file:
content = file.read()
print(content)
with open('dest.txt','w') as file:
file.write(content)
with open('example.txt','r') as file:
for line in file:
print(line.strip())
with open('example.txt','w') as file:
file.write('hello \n')
file.write("world \n")
#overrides
with open('example.txt','a') as file:
file.write("text is appended")
lines = ["there are \n","infinte stars \n","in universe"]
with open('example.txt','a') as file:
file.writelines(lines)
with open('source.txt','w+') as file:
file.write("hiii my name is divisha gupta \n")
file.write("hiii my name is divisha gupta \n")
#file.seek(0)
with open('source.txt','r') as file:
cont = file.read()
print(cont)