-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (27 loc) · 800 Bytes
/
main.py
File metadata and controls
53 lines (27 loc) · 800 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from pathlib import Path
def readfileandfolder():
path=Path('')
items=list(path.rglob('*'))
for i, item in enumerate(items):
print(f"{i+1} : {item}")
def creatfile():
try:
readfileandfolder()
name=input("enter your file name:")
p=Path(name)
if not p.exists():
with open(p,"w") as fs:
data=input("enter your data:")
fs.write(data)
print(f"{name} created successfully")
else:
print(f"{name} already exists")
except Exception as e:
print("An error occurred:",e)
print("Press 1 for creating a file")
print("Press 2 for reading a file")
print("Press 3 for updating a file")
print("Press 4 for deleting a file")
check=int(input("Enter your choice:"))
if check==1:
creatfile()