반응형
/************************************************************************************************
-- Title : [PY2.7.11] 함수와 클래스의 비교
-- Reference : itsdong.com
-- Key word : class 클래스
************************************************************************************************/
# -*- coding: utf-8 -*-
# -------------------------------------------------
# -- 함수 이용 예
# -------------------------------------------------
def person(name, age):
showinfo = name + '은 '+ age + '살이다.'
return showinfo
ttt = person('홍길동', '24')
print(ttt)
# -------------------------------------------------
# -- 클래스 이용 예
# -------------------------------------------------
class Person:
def __Init__(self):
self.Info = ''
def ShowInfo(self, name, age):
self.Info = name + '은 '+ age + '살이다.'
print(self.Info)
man = Person()
woman = Person()
man.ShowInfo('홍길동', '18')
woman.ShowInfo('홍길순', '16')
반응형