跟老齐学Python之编写类之三子类

1182次阅读  |  发布于5年以前

关于类,看官想必已经有了感觉,看下面的代码,请仔细阅读,并看看是否能够发现点什么问题呢?

复制代码 代码如下:

!/usr/bin/env python

coding:utf-8

class Person:
def init(self, name, lang, email):
self.name = name
self.lang = lang
self.email = email

def author(self):  
    return self.name

class Programmer:
def init(self, name, lang, email, system, website):
self.name = name
self.lang = lang
self.email = email
self.system = system
self.website = website

def pythoner(self):  
    pythoner_list = [ self.name, self.lang, self.email, self.system, self.website ]  
    return pythoner_list

if name=="main":
writer = Person("qiwsir","Chinese","qiwsir@gmail.com")
python = Programmer("qiwsir","Python","qiwsir@gmail.com","Ubutun","qiwsir.github.io")
print "My name is:%s"%writer.author()
print "I write program by:%s"%python.pythoner()[1]

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8