跟老齐学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 生日广州男生祝福语简短