-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileoperation.py
More file actions
99 lines (73 loc) · 1.62 KB
/
fileoperation.py
File metadata and controls
99 lines (73 loc) · 1.62 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
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
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 17 10:24:02 2019
@author: Patil
"""
def write(name,path):
file=str(path)+'\\'+str(name)
f=open(str(file),'w')
print('Enter Content + @ at the end : ')
s=''
while(s!='@'):
s=input()
if s!='@':
f.write(s)
print('File Successful')
f.close()
def read(name,path):
file=str(path)+'\\'+str(name)
f=open(str(file),'r')
print(f.read())
f.close()
def append(name,path):
file=str(path)+'\\'+str(name)
f=open(str(file),'a+')
print('Enter Content @ : ')
s=''
while(s!='@'):
s=input()
if s!='@':
f.write(s)
print('Write Successful')
print(f.read())
f.close()
ch=1
name=input('File Name with ext : ')
path = input('Enter Directory : ')
while ch==1:
print('1.Write 2.Read 3. Append')
op=int(input('Enter Option : '))
if op==1 :
write(name,path)
elif op==2 :
read(name,path)
elif op==3 :
append(name,path)
else : print('Invalid')
ch=int(input('Continue 1/0 :'))
'''
File Name with ext : hello5.txt
Enter Directory : C:\Chaitanya\Python
1.Write 2.Read 3. Append
Enter Option : 1
Enter Content + @ at the end :
Hello World
@
File Successful
Continue 1/0 :1
1.Write 2.Read 3. Append
Enter Option : 2
Hello World
Continue 1/0 :1
1.Write 2.Read 3. Append
Enter Option : 3
Enter Content @ :
Hello There
@
Write Successful
Continue 1/0 :1
1.Write 2.Read 3. Append
Enter Option : 2
Hello World Hello There
Continue 1/0 :0
'''