我正在尝试在 Eclipse 中使用 PyDev 创建一个类,但是当我尝试作为 Python 运行时出现错误: TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
.
我尝试选择所有文本,然后在源菜单下选择“正确缩进”,但我在 Eclipse 中找不到该选项。
如何在 Python 3 中解决这个问题?
这是代码(从此处转录):
class Employee:
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print("Total Employee %d") % Employee.empCount
def displayEmployee(self):
print ("Name:"), self.name, "Salary: ", self.salary
def main():
emp1 = Employee("Zara", 2000)
emp2 = Employee("Manni", 5000)
emp1.displayEmployee()
emp2.displayEmployee()
print("Total Employee %d") % Employee.empCount
if __name__ == '__main__':
main()