1. main menu
- 연락처 등록
- 연락처 조회 
- 연락처 삭제 : 이름으로 검색 후 동일 이름 전화번호 출력시켜서 삭제할 이름의 번호 입력하면 삭제되도록
- 연락처 출력
- (연락처 변경도 해보자)
- 프로그램 종료

2. 등록
- 이름
- 연락처
- 이메일

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
user = []
def start():
 
    while True:
        num = int(input("\n연락처 메뉴 [1.등록   2.조회   3.삭제   4.출력  5.수정  6.종료]   선택 = "))
        if num == 1:
            print("\n================= 연락처 등록 ================")
            user.append(Address())
        elif num == 2:
            name = input("조회할 이름을 입력하세요 : ")
            print("\n================= 연락처 조회 ================")
            if not user_print(name):
                print("\n조회 결과가 없습니다.")
        elif num == 3:
            print("\n================= 연락처 삭제 ================")
            name = input("\n삭제할 이름을 입력하세요 : ")
            if user_print(name):
                delnum = int(input("\n삭제할 번호를 입력하세요 :"))
                del(user[delnum-1])
                print("\n삭제되었습니다.")
        elif num == 4:
            print("\n================= 연락처 전체 조회 ================")
            if len(user) != 0 :
                user_print("all")
            else :
                print("\n조회 결과가 없습니다.")
        elif num == 5:
            print("\n================= 연락처 수정 ================")
            name = input("\n변경할 이름을 입력하세요 : ")
            if user_print(name):
                delnum = int(input("\n변경할 번호를 입력하세요 :"))
                chnum = int(input("\n변경할 항목 선택 (1. 이름, 2. 전화번호, 3.이메일) : "))
                if chnum == 1:
                    user[delnum-1].setname(input("변경 이름 : "))
                elif chnum == 2:
                    user[delnum-1].settell(input("변경 전화번호 : "))
                elif chnum == 3:
                    user[delnum-1].setemail(input("변경 이메일 : "))
                else:
                    print("\n잘못입력하셨습니다")
            else:
                print("\n변경할 이름이 없습니다.")
        elif num == 6:
            break
        else:
            print("다시 입력하세요")
            
def user_print(name):
    if name == "all":
        for i in range(0len(user)):
            print(i+1,end=" ")
            user[i].disp()
        return
    else:
        for i in range(0len(user)):
            if user[i].name == name :
                print(i+1,end=" ")
                user[i].disp()
        return True
    return False
    
class Address:
    def __init__(self):
        self.name = input("이름 입력 : ")
        self.tell = input("전화번호 입력 :")
        self.email = input("이메일 입력 :")
    def setname(self, name):
        self.name = name
    def settell(self, tell):
        self.tell = tell
    def setemail(self, email):
        self.email = email
    def disp(self):
        print(self.name," ",self.tell," ",self.email)
        
if __name__ == "__main__":
    start()
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

'Python' 카테고리의 다른 글

급여관리.py  (0) 2019.07.25
숫자야구파일.py  (0) 2019.07.25
슬라이스  (0) 2019.07.10
시퀀스 자료형  (0) 2019.07.10
리스트, 튜플  (0) 2019.07.10

+ Recent posts