首页 > 编程语言 > 详细

python 面向对象

时间:2017-01-04 07:57:10      阅读:207      评论:0      收藏:0      [点我收藏+]
class Peoson(object):
#self代表自己
    def __init__(self,name,age):
        self.name=name
        self.age=age
#self 强制参数
    def run(self):
        print "%s is running.." % self.name
    def speak(self,msg):
        print "%s: %s is speaking.." % (self.name,msg)
p1=Peoson("jack",23)
p1.run()
p1.speak("hello")

python 面向对象

原文:http://liangey.blog.51cto.com/9097868/1888729

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!