创建一个银行员工类,python,创建两个员工对象
时间: 2023-09-16 17:07:40 浏览: 63
Python 使用元类type创建类对象常见应用详解
好的,以下是创建银行员工类的Python代码,同时创建两个员工对象:
```python
class BankEmployee:
def __init__(self, name, id_number, position, salary):
self.name = name
self.id_number = id_number
self.position = position
self.salary = salary
def display_employee_details(self):
print(f"Name: {self.name}")
print(f"ID Number: {self.id_number}")
print(f"Position: {self.position}")
print(f"Salary: {self.salary}")
employee1 = BankEmployee("John Doe", "123456789", "Manager", 50000)
employee2 = BankEmployee("Jane Smith", "987654321", "Teller", 25000)
employee1.display_employee_details()
employee2.display_employee_details()
```
输出:
```
Name: John Doe
ID Number: 123456789
Position: Manager
Salary: 50000
Name: Jane Smith
ID Number: 987654321
Position: Teller
Salary: 25000
```
阅读全文