class Employee:
def __int__(self, name, salary):
self.name = name
self.salary = salary
def getsalary(self):
print( self.salary)
rohan = Employee("Rohan","345500")
print(rohan.salary)
print(rohan.name)
#rohan.getsalary()
harry = Employee("Harry", "521000")
print(harry.salary)
print(harry.name)
能找到刚才说的那个意想不到的论点是什么问题。谁能解决这个问题或帮助我
输出:- 结果应该是 345500 罗汉 521000 哈利
这是
__init__
方法的拼写错误。
class Employee:
def __init__(self, name, salary):
self.name = name
self.salary = salary
def getsalary(self):
print( self.salary)
rohan = Employee("Rohan","345500")
print(rohan.salary)
print(rohan.name)
#rohan.getsalary()
harry = Employee("Harry", "521000")
print(harry.salary)
print(harry.name)