본문 바로가기

프로그래밍언어/Python예제4

고객관리프로그램(클래스함수정의) class Customer(): def __init__(self): self.custlist=[{'name':'hong1','gender':'M',"email":'hong1@gmail.com',"birthyear":'2000'}, {'name':'hong2','gender':'M',"email":'hong2@gmail.com',"birthyear":'2000'}, {'name':'hong3','gender':'M',"email":'hong3@gmail.com',"birthyear":'2000'}, {'name':'hong4','gender':'M',"email":'hong4@gmail.com',"birthyear":'2000'}] self.page=3 while True: self.exe(self.dis.. 2023. 2. 17.
고객관리프로그램(클래스최종) from customer import Customer Customer() # cus = Customer() # while True: # choice=input(''' # ---------------------------------------- # 다음 중에서 하실 일을 골라주세요 : # I - 고객 정보 입력 # C - 현재 고객 정보 조회 # P - 이전 고객 정보 조회 # N - 다음 고객 정보 조회 # U - 고객 정보 수정 # D - 고객 정보 삭제 # Q - 프로그램 종료 # ---------------------------------------- # ''').upper() # if choice=="I": # cus.insert_data() # elif choice=="C": # cus.curr.. 2023. 2. 17.
고객관리프로그램(함수) import re def insert_data(custlist): customer={'name':'','gender':'',"email":'',"birthyear":''} customer['name'] = input('이름 >>> ') while True: customer['gender'] = input('성별(M,m or F,f) >>> ').upper() if customer['gender'] in ('M','F'): break while True: customer['email'] = input('이메일 >>> ') check=None for idx, i in enumerate(custlist): if i['email'] == customer['email']: check=idx break if che.. 2023. 2. 17.
고객관리프로그램(예시) ''' 콘솔형 고객 정보 관리 시스템 구축 1. 기능 : 고객 정보 입력(I), 현재/이전/다음 고객 정보 조회(C/P/N), 고객 정보 수정(U), 고객 정보 삭제(D), 고객 정보 종료(Q) 괄호 안 영문자를 입력하면 각 기능이 구현되게 만든다 종료(Q)를 입력하기 전까지 기능 선택 메시지가 계속 뜨도록 만든다 입력된 각 정보는 인덱스 값에 따라 페이지를 가진다 -> 첫 정보 입력시 인덱스는 0이므로, 입력 전 기본 page 값은 -1로 설정한다 2. 입력(I) dictionary로 각 키의 값을 받고 빈 리스트에 채워나간다 성별(sex) : M, m, F, f로만 입력 가능 -> 소문자로 입력하는 경우 대문자로 자동 변환 -> sex 값이 M 또는 F가 아닐 경우 다시 입력 이메일(email) : .. 2023. 2. 17.