跟老齐学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 好听的元旦简短祝福语