-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFile_handling.py
103 lines (75 loc) · 1.73 KB
/
File_handling.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
print("Enter the Name of Source File: ")
sFile = input()
print("Enter the Name of Target File: ")
tFile = input()
fileHandle = open(sFile, "r")
texts = fileHandle.readlines()
fileHandle.close()
fileHandle = open(tFile, "w")
for s in texts:
fileHandle.write(s)
fileHandle.close()
print("\nFile Copied Successfully!")
f=open("om.txt","r")
while 1:
char=f.read(1)
if not char:
break
print(char)
f.close()
count = 0
number = int(input("enter the number:"))
while number > 10:
number = number // 6
count = count + 1
print(count)
f = open("om.txt", "w+")
f.write("om is the best")
f.close()
f = open("om.txt", "r")
for line in f:
output = line.title()
print(output)
letter = input("enter letter:")
f = open("om.txt", "r")
m = f.read()
c = m.count(letter)
print(c)
f = open("om.txt", "w")
f.write("hatttttt")
f.close()
f = open("om.txt", "r")
for line in f:
print(line)
f.close()
f = open("om.txt", "a")
f.write("\naditya is also good")
f.close()
f = open("om.txt", "r")
for line in f:
print(line)
f = open("om.txt", "r")
for line in f:
print(line)
fn1 = input("enter the name of first file:")
fn2 = input("enter the name of 2nd file:")
f1 = open(fn1, "r")
f2 = open(fn2, "w")
for line in f1:
f2.write(line)
f1.close()
f2.close()
f2 = f2 = open(fn2, "r")
for line in f2:
print(line)
f = open("om.txt", "w")
n = int(input("enter the no. of students:"))
while n > 0:
a_id = input("enter student id:")
name = input("enter student name:")
n = n - 1
f.write("name:" + name + " id: " + a_id + "\n")
f.close()
f = open("om.txt", "r")
for line in f:
print(line)