-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfiles.py
More file actions
53 lines (44 loc) · 1.09 KB
/
files.py
File metadata and controls
53 lines (44 loc) · 1.09 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os;
file1 = open("f1.txt","w")
if file1:
print("file is opened successfully")
file1.close()
#try:
# file2 = open("f2.txt","r")
#finally:
# print("finally block excuted")
print("opening file")
f2 = open("f2.txt","r")
print(f2.read())
f2 = open("f1.txt","w")
f2.write(''' python is modern day language
its easy to understand''')
f2.close()
f2 = open("f2.txt","w")
f2.write(''' python is modern day language
its easy to understand''')
f2.close()
f2 = open("f2.txt","a")
f2.write(''' this is append txt python is modern day language
its easy to understand''')
f2.close()
f2 = open("f2.txt","r")
for i in f2:
print(i)
f2 = open("f2.txt","r")
c = f2.readline()
c1 = f2.readline()
print(c)
print(c1)
f2.close()
#fileptr = open("file2.txt","x")
#print(fileptr)
#if fileptr:
# print("File created successfully")
fileptr = open("f2.txt","r")
print("The filepointer is at byte :",fileptr.tell())
c2 = fileptr.read()
print("after reading,file pointer at..",fileptr.tell())
fileptr.close()
#os.rename("f1.txt","file1.txt")
#os.remove("file1.txt")