forked from Likelion-At-Smu/Backend-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2주차과제.py
More file actions
70 lines (62 loc) · 2.02 KB
/
Copy path2주차과제.py
File metadata and controls
70 lines (62 loc) · 2.02 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
def print_menue():
print(chr(0x1F981))
print("-"*14+chr(0x1F981)+" 멋쟁이 사자처럼 전화번호부 "+chr(0x1F981)+"-"*14)
print("-"*10+"1) 추가 2) 조회 3) 수정 4) 삭제 q) 종료"+"-"*10)
print("-"*53)
print()
print("원하시는 메뉴를 입력해주세요: ",end="")
def add():
print("이름을 입력해주세요 : ",end="")
name = input()
print(name+"님의 번호를 입력해주세요 : ",end="")
num = input()
print(name+"님의 메일를 입력해주세요 : ",end = "")
mail = input()
phone_book[name]={"이름":name,"전화번호":num,"메일":mail}
print()
def search():
print("조회를 원하는 이름을 입력해주세요 : ",end="")
name = input()
if name in phone_book:
print(phone_book[name])
print()
def adjustment():
print("수정을 원하는 이름을 입력해주세요 : ",end="")
name = input()
print("수정을 원하는 항목과 이름을 입력해주세요 : ",end="")
key, value = input().split()
if name in phone_book:
phone_book[name][key]=value
if key=="이름":
phone_book[key]=phone_book[name]
del phone_book[name]
print()
def delete():
print("삭제를 원하는 이름을 입력해주세요 : ",end="")
name = input()
if name in phone_book:
del phone_book[name]
print()
if __name__=="__main__":
phone_book={}
while True:
print_menue()
cmd = input()
if cmd == '1':
add()
continue
elif cmd == '2':
search()
continue
elif cmd == '3':
try:
adjustment()
continue
# 에러가 발생할 가능성이 있는 코드
except Exception as ex: # 에러 종류
print('에러가 발생 했습니다', ex) # ex는 발생한 에러의 이름을 받아오는 변수
elif cmd == '4':
delete()
continue
elif cmd == 'q':
break