首页 > 其他 > 详细

repr方法字符串输出实例对象的值

时间:2018-06-26 10:07:10      阅读:132      评论:0      收藏:0      [点我收藏+]
#coding=utf-8
#repr方法字符串输出实例对象的值
class CountFromBy(object):

    def __init__(self, val=0, incr=1):
        self.val = val
        self.incr = incr

    def increase(self):
        self.val += self.incr

    def __repr__(self):
        return str(self.val)


>>> c = CountFromBy()
>>> c
0

 

repr方法字符串输出实例对象的值

原文:https://www.cnblogs.com/themost/p/9227256.html

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