跟老齐学Python之编写类之二方法
数据流转过程
除了在类中可以写这种函数之外,在类中还可以写别的函数,延续上一讲的例子:
#!/usr/bin/envpython #coding:utf-8
classPerson: def__init__(self,name,lang="golang",website="www.google.com"): self.name=name self.lang=lang self.website=website self.email="qiwsir@gmail.com"
defauthor(self): returnself.name
laoqi=Person("LaoQi") info=Person("qiwsir",lang="python",website="qiwsir.github.io")
print"Authornamefromlaoqi:",laoqi.author() print"Authornamefrominfo:",info.author()
#运行结果
Authornamefromlaoqi:LaoQi Authornamefrominfo:qiwsir
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短