1
zhusimaji 2017-07-03 23:42:00 +08:00
给楼主贴一段代码吧
#!/usr/bin/python class test: def method(self): print('hello world') a=test() print(getattr(a,'method','default')()) print(getattr(test,'method','default')()) 输出结果 hello world None Traceback (most recent call last): File "/usercode/file3.py", line 8, in <module> print(getattr(test,'method','default')()) TypeError: method() missing 1 required positional argument: 'self' 楼主你自己的代码需要传递实例 |