小编and*_*lis的帖子

为什么类方法不被调用?

我试图调用类方法"func",它应该打印一些东西,但它永远不会被打印......没有错误,只是沉默.代码如下:

class AnyClass():
    atr1=0
    atr2='text'

    def func():
        print ('Ran Func')

a = AnyClass()
a.func
Run Code Online (Sandbox Code Playgroud)

python methods class python-3.x

-3
推荐指数
1
解决办法
46
查看次数

标签 统计

class ×1

methods ×1

python ×1

python-3.x ×1