更改类中的默认参数

时间:2019-07-20 06:33:31

标签: python python-2.7

如何更改在类之外的另一个函数中调用的参数值?

class test():
     def a(self,txt="aaa"):
        return txt

    def b(self):
        print self.a()
        print 'bbb'

foo = test()
foo.a("ccc")
foo.b()

想要返回“ ccc”,“ bbb”

0 个答案:

没有答案
相关问题