Cant pass object variable to object method as default value

This question already has an answer here:

  • How to pass a default argument value of an instance member to a method? 3 answers

  • 尝试这个

    class TrabGraph:
        def circle(self):
            print (self.radius)
        def __init__(self,radius):            
            self.radius = radius
    
    TrabGraph(2).circle()
    
    链接地址: http://www.djcxy.com/p/78568.html

    上一篇: 如何检测脚本所需的最低版本的python

    下一篇: 无法将对象变量作为默认值传递给对象方法