我的代码如下:
class A:
def TestMethod(self):
print 'first method'
def TestMethod(self, i):
print 'second method', i
ob = A()
ob.TestMethod()
ob.TestMethod(10)
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误..
Traceback (most recent call last):
File "stack.py", line 9, in <module>
ob.TestMethod()
TypeError: TestMethod() takes exactly 2 arguments (1 given)
Run Code Online (Sandbox Code Playgroud)
如何使用不同数量的参数调用方法?
python ×1