halo!好久不見,很久沒寫部落格,一直想要找回當初在學校裡敲**學習的狀態,所以現在雖然做著簡單枯燥的軟測工作,但是也有開始學習python,下面就是最入門級的乙個員工管理系統,算是對python基本語法學習完的交代。
#員工管理系統
#定義乙個員工資訊字典
employee = {}
# 1、顯示選單
def show_menu():
print("*" * 30)
print("員工管理系統 v2.0")
print(" 1:新增員工資訊")
print(" 2:刪除員工資訊")
print(" 3:編輯員工資訊")
print(" 4:檢視所有員工資訊")
print(" 5:檢視具體員工資訊")
print(" 6:退出員工系統")
print("*" * 30)
# 2、顯示所有資訊
def show_all_info():
for em_number in employee:
# print(employee)
print("員工編號:" + em_number +
", 員工姓名:" + employee[em_number]['name'] +
", 員工薪水:" + employee[em_number]['salary'] +
", 員工性別:" + employee[em_number]['***'])
#3、根據員工編號檢視員工資訊
def show_single_info():
em_number = input("請輸入要檢視的員工編號:")
em_name = employee[em_number]['name']
em_salary = employee[em_number]['salary']
em_*** = employee[em_number]['***']
print("姓名:" + em_name + " 薪水:" + em_salary + " 性別:" + em_***)
# 4、新增員工
def add():
em_number = input("請輸入員工編號:")
em_name = input("請輸入員工姓名:")
em_salary = input("請輸入員工薪水:")
em_*** = input("請輸入員工性別:")
em_info =
employee[em_number] = em_info
print("新增員工成功!請按4檢視所有員工資訊")
#5、編輯員工資訊
def edit():
em_number = input("請輸入員工編號:")
if em_number not in employee:
print("您輸入的員工編號不存在!")
return
new_name = input("請輸入新的員工姓名:")
new_salary = input("請輸入新的員工薪水:")
new_*** = input("請輸入新的員工性別:")
employee[em_number]['name'] = new_name
employee[em_number]['salary'] = new_salary
employee[em_number]['***'] = new_***
print("編輯員工編號為" + em_number + "的員工資訊成功")
#6、刪除員工
def delete():
em_number = input("請輸入員工編號:")
if em_number not in employee:
print("您輸入的員工編號不存在!")
return
del employee[em_number]
print("刪除員工編號為" + em_number + "的員工成功")
#main方法
def main():
show_menu()
while true:
user_operate = input("請輸入您的操作:")
if user_operate == '1':
add()
elif user_operate == '2':
delete()
elif user_operate == '3':
edit()
elif user_operate == '4':
show_all_info()
elif user_operate == '5':
show_single_info()
elif user_operate == '6':
print("歡迎下次登入員工管理系統!!")
break
else:
print("您的操作有誤,請重新操作!")
main()
入門級python測試
測量粒度 提示資訊一般為對應條件成立時的文字描述 斷言 例項 def func div num1,num2 除法 assert num2 0,num2不能為0 assert isinstance num1,int,float num1應為數字型別 assert isinstance num2,int...
python 入門級環境配置
由個人經驗得知,在學習一門新的計算機程式語言的時候,實踐至上.要想實踐,對應的環境是不可少的,一下簡單介紹python環境.由一下幾個方面組成 sublime text 安裝 sublime text 配置 對於配置sublime text 3 沒有什麼特殊的,就是要乙個基本的package con...
Python入門級組員驗證程式
group grace bill cindy alice frank bob print group while1 1 try name input 輸入姓名以驗證 group.remove name except print 未找到組員,或已被驗證過,或程式出錯。請確保沒有錯別字,然後再試一次 e...