在我的类DemoOperator中,结果显示AttributeError:DemoOperator实例没有属性“optr\u jumlah”。请告诉我哪里是编码错误和修改什么。你知道吗
#program latian
class DemoOperator:
def __init__(self):
#input data x dan y
x = raw_input("Masukkan x : ")
y = raw_input("Masukkan y : ")
self.optr_jumlah(int(x), int(y))
self.optr_kurang(int(x), int(y))
self.optr_kali(int(x), int(y))
self.optr_bagi(int(x), int(y))
self.optr_modulus(int(x), int(y))
def optr_jumlah(self, a, b):
a += b
print "x += y hasilnya ",a
def optr_kurang(self, a, b):
a -= b
print "x -= y hasilnya ",a
def optr_kali(self, a, b):
a *= b
print "x *= y hasilnya ",a
def optr_bagi(self, a, b):
a /= b
print "x /= y hasilnya ",a
def optr_modulus(self, a, b):
a %= b
print "x %= y hasilnya ",a
if __name__ == '__main__':
aplikasi = DemoOperator()
下面是上面代码显示的一些错误:
Traceback (most recent call last):
File "E:\Kuliah\python\demoOperator.py", line 34, in <module>
aplikasi = DemoOperator()
File "E:\Kuliah\python\demoOperator.py", line 7, in __init__
self.optr_jumlah(int(x), int(y))
AttributeError: DemoOperator instance has no attribute 'optr_jumlah'
谢谢你回答我的问题。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐