面向对象编程-类的继承-person

#!/usr/bin/env python

class Person:

  def__init__(self,Type,Sex,Age,Name):

    self.race =Type

    self.sex = Sex

    self.age = Age

    self.name =Name

  deftalk(self,msg=0):

    self.msg = msg

    if self.msg !=0:

      printself.name,'saying:',self.msg

class person_info(Person):

  def__init__(self,Type,Sex,Age,Name,nation,work,salary):

   Person.__init__(self,Type,Sex,Age,Name)

    self.country =nation

    self.jog = work

    self.salary =salary

  def tell(self):

    print '%s\'spersonal information:Name:%s,Age:%s,Sex:%s'%(self.name,self.name,self.age,self.sex)

p=person_info('1','Male','34','rsc','CN','IT','6000')

p.tell()

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS