我解决了间距问题,并在很长一段时间内纠正了其他错误。现在它正在做我想做的事情,但我选择了选项 2,它将打印出员工的记录 4 次。如果我输入另一名员工,它只会打印第二个而不是第一个。
class EmployeeClass:
def Employee(name, lastName, age, salary):
name = name
lastName = lastName
age = age
salary = salary
def displayEmployee(x):
print("Name: " + name + ", " + lastName)
print("Age: " + age)
print("Salary: " + salary)
EmployeeArray = []
Continue = True
print ("Employee Information V2.0")
while Continue == True:
print ("Welcome to Employee Information")
print ("1: Add New Record")
print ("2: List Records")
print ("3: Quit")
choice = input()
if choice == "1":
name = input ("Enter First Name: ")
EmployeeArray.append(name)
if name == "":
Continue = False
print ("Goodbye!")
break
lastName = input ("Enter Last Name: ")
EmployeeArray.append(lastName)
age = input ("Enter Age: ")
EmployeeArray.append(age)
salary = input ("Enter Salary: ")
EmployeeArray.append(salary)
elif choice == "2":
for Employee in EmployeeArray:
EmployeeClass.displayEmployee(Employee)
Continue = False
elif choice == "3":
print ("Bye!")
break
else:
print ("Please choose a valid option")
print ("\n")