반응형
class BusinessCard:
def __init__(self):
self.name = 'empty'
self.email = 'empty'
self.addr = 'empty'
def set_info(self, name, email, addr):
self.name = name
self.email = email
self.addr = addr
def show_info(self):
print('-'*30)
print('Name: ', self.name)
print('E-mail: ', self.email)
print('Address: ', self.addr)
print('-'*30)
card = BusinessCard()
card.show_info()
card.set_info('JohnMark','practice1356@gmail.com','Seoul Mapo')
card.show_info()
실행결과
$ py constructor.py
------------------------------
Name: empty
E-mail: empty
Address: empty
------------------------------
------------------------------
Name: JohnMark
E-mail: practice1356@gmail.com
Address: Seoul Mapo
------------------------------
반응형
'Programming > Python' 카테고리의 다른 글
[Python-Basic] Class Data Type - 4(Namespace) (0) | 2019.11.05 |
---|---|
[Python-Basic] Class Data Type - 3(Inheritance) (0) | 2019.11.05 |
[Python-Basic] Class Data Type - 2(Instance) (0) | 2019.11.05 |
[Python-Basic] Class Data Type - 1 (0) | 2019.11.05 |
[Python-Basic] Tuple Data Type - 1 (0) | 2019.11.05 |