【发布时间】:2017-04-03 00:54:18
【问题描述】:
我得到一个 TypeError: unbound method mult() must be called with calculadora instance 作为第一个参数(取而代之的是 int 实例)
运行我的 python 文件时:
from __future__ import print_function
class calculadora:
def suma(x,y):
added = x + y
print(added)
def resta(x,y):
sub = x - y
print(sub)
def mult(x,y):
multi = x * y
print(multi)
calculadora.mult(3,5)
【问题讨论】:
-
您是打算在这里尝试创建静态方法,还是要实例方法?
-
@idjaw 我想要实例方法
标签: python python-2.7