最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python實(shí)現(xiàn)員工管理系統(tǒng)

 更新時(shí)間:2018年01月11日 11:16:32   投稿:lijiao  
這篇文章主要介紹了python實(shí)現(xiàn)員工管理系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

這是一個(gè)簡(jiǎn)易的員工管理系統(tǒng),實(shí)現(xiàn)最簡(jiǎn)單的功能:

1.登錄用戶(hù)密碼驗(yàn)證(錯(cuò)誤三次自動(dòng)退出)
2.支持文本員工的搜索、添加、刪除、修改
3.一級(jí)層級(jí)多個(gè)選項(xiàng)、二級(jí)層級(jí)多個(gè)選項(xiàng),都支持判空、退出、返回上一層級(jí)
4.針對(duì)刪除和修改有員工當(dāng)前自動(dòng)搜索到的結(jié)果進(jìn)行參照修改和特殊提醒是否刪除

用到的基礎(chǔ)知識(shí)點(diǎn)比較多:

1.計(jì)數(shù)器
2.while True 以及給while做退出層級(jí)標(biāo)記
3.if…elif…else 的嵌套使用
4.continue 和 break 以及簡(jiǎn)單函數(shù)定義def
5.鍵盤(pán)抓取 raw_input 以及通過(guò) os.system(‘clear')來(lái)調(diào)用linux中shell下的命令。
6.文本的讀取寫(xiě)入原理(單讀的不能實(shí)際寫(xiě)入,只能通過(guò)轉(zhuǎn)存文本覆蓋寫(xiě)入。)
如果是‘a(chǎn)+'則只為讀取并可通過(guò)'writelines()'來(lái)寫(xiě)入,是追加寫(xiě)入
如果是‘w+'則為寫(xiě)入,可通過(guò)‘writelines()'來(lái)寫(xiě)入,是覆蓋寫(xiě)入
7.列表的構(gòu)成原理,列表的轉(zhuǎn)換,列表的定位以及下標(biāo)獲取 listname.index(line)
8.特別需要注意程序執(zhí)行前后順序以及嚴(yán)格的縮進(jìn)格式

#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import sys
import os

#系統(tǒng)的用戶(hù)登錄
#os.system('clear')
time = 0
while True: #this is login
  if time < 3:
    name = raw_input("\033[1mplease input your login account:").strip()
    passwd = raw_input("\033[1mplease input your login password:").strip()
    if len(name) == 0:        #.strip()意為去除空格
      print("\033[31mIt's not allow empty input!\n")
      continue
    elif name == 'zhangjun' and passwd == '123.com':
      print("\033[32mYour account and password right!")
      pass
    else:
      print("\033[31mYour account or password error!")
      time += 1
      continue
    break
  else:
    print("\033[31mYou are wrong three times, has already quit from the system!")
    sys.exit()

#系統(tǒng)的選擇界面
#os.system('clear')
print ('\n')
def display(): #進(jìn)行登陸后界面的函數(shù)定義,方便在下面的選用層級(jí)后,返回上一層時(shí),依然可以看到選擇大屏。
 print("\033[34m########################################################################")
 print("\033[34m\t######### \033[1;32mWelcome to this employee search system!\033[0;34m #########")
 print("\033[34m\t\t#################################################")
 print("\n")
 print("\033[32m\033[1m\t\t\t1\033[33m\033[1m.Search.(you can search the infomation for employee!)\n")
 print("\033[32m\033[1m\t\t\t2\033[33m\033[1m.Add.(Add a user into this employee system!)\n")
 print("\033[32m\033[1m\t\t\t3\033[33m\033[1m.Delete.(Delete a user from this employee system!)\n")
 print("\033[32m\033[1m\t\t\t4\033[33m\033[1m.Modify.(You can modify something infomation in this employee system!)\n")
 print("\033[32m\033[1m\t\t\t5\033[33m\033[1m.Quit.(quit this employee system!)\n")
 print("\n")
 dict ()
#指定文件路徑
path = 'D:\Users\Franzhang\employee_list.txt'
#定義while層級(jí)標(biāo)記break_tag1 = 0 以及登陸初始提示
break_tag1 = 0
while break_tag1 == 0:
 display()
 select_input = raw_input ("\033[37m\033[1mplease input you want to select items:").strip ()
 if len(select_input) == 0:
  continue
 elif select_input == 'quit':
  sys.exit ()
 #選項(xiàng)1進(jìn)行模糊搜索
 elif int(select_input) == 1:
  # os.system('clear')
  break_tag2 = 0
  while break_tag2 == 0:
   content_open = open (path)
   search_input = raw_input ("please input your need (SEARCH MODE):").strip ()
   for line in content_open:
    if len (search_input) == 0:
     continue
    elif search_input in line:
     print line
    else:
     if search_input == 'all': #展示文本目前所有員工
      print line
     elif search_input == 'quit':
      break_tag2 = 1 #返回上一層級(jí)選擇項(xiàng)
 #選項(xiàng)2進(jìn)行員工信息添加(其實(shí)是添加了一行列表)
 elif int(select_input) == 2:
  # os.system('clear')
  content_write = file (path, 'a+') #讀入文本
  break_tag3 = 0
  while break_tag3 == 0:
   addid_input = raw_input ("please input your need (ADD_ID):").strip ()
   if len (addid_input) == 0:
    continue
   elif addid_input == 'quit':
    break_tag3 = 1
    content_write.close () #文本使用完畢后需要關(guān)閉,以免占用內(nèi)存。
    break
   addname_input = raw_input ("please input your need (ADD_NAME):").strip ()
   if len (addid_input) == 0:
    continue
   elif addname_input == 'quit':
    break_tag3 = 1
    content_write.close ()
    break
   addage_input = raw_input ("please input your need (ADD_AGE):").strip ()
   if len (addid_input) == 0:
    continue
   elif addage_input == 'quit':
    break_tag3 = 1
    content_write.close ()
    break
   adddpt_input = raw_input ("please input your need (ADD_DPT):").strip ()
   if len (addid_input) == 0:
    continue
   elif adddpt_input == 'quit':
    break_tag3 = 1
    content_write.close ()
    break
   addphone_input = raw_input ("please input your need (ADD_phone):").strip ()
   if len (addid_input) == 0:
    continue
   elif addphone_input == 'quit':
    break_tag3 = 1
    content_write.close ()
    break
   list_add = [addid_input, '\t', addname_input, '\t', addage_input, '\t', adddpt_input, '\t', addphone_input,'\n'] #將上面的單項(xiàng)錄入寫(xiě)入列表list_add
   content_write.writelines (list_add) #將列表追加寫(xiě)入文本
   print("It's already insert the list!")
   continue
 #選項(xiàng)3進(jìn)行員工刪除
 elif int(select_input) == 3:
  # os.system('clear')
  break_tag4 = 0
  while break_tag4 == 0:
   content_opend = open (path)
   delete_input = raw_input ("please input your need (DELETE):").strip ()
   if len (delete_input) == 0:
    continue
   elif delete_input == 'quit':
    break_tag4 = 1
   for line in content_opend:
    if delete_input in line:
     print line
     sure = raw_input ("Are you sure delete this account line ? (yes/no):").strip ()
     if len (sure) == 0:
      continue
     elif sure == 'yes':
      inside = file (path, 'a+') 
      bebe = inside.readlines () #按行讀入文本并轉(zhuǎn)換為列表data
      data = list (bebe) 
      for i in data:
       if delete_input in i: 
        w = data.index (i) #獲取輸入的員工在整個(gè)文本列表的位置
        del data[w] #刪除單行
      data_in = data #轉(zhuǎn)存刪除后的文本列表(這個(gè)時(shí)候被讀取的經(jīng)過(guò)刪除后的內(nèi)容還在內(nèi)存中。)
      inside.close () #轉(zhuǎn)存后在關(guān)閉文本,否則導(dǎo)致轉(zhuǎn)存因提前關(guān)閉而無(wú)效。
      inside_w = file (path, 'w+') #再次以覆蓋寫(xiě)入方式讀取文本
      inside_w.writelines (data_in) #將剛才轉(zhuǎn)存的文本寫(xiě)入
      inside_w.close () #關(guān)閉文本后會(huì)自動(dòng)保存寫(xiě)入
      break
     elif sure == 'no':
      break
    continue
 #選項(xiàng)4進(jìn)行員工信息更改(整條員工信息的更改)
 elif int(select_input) == 4:
  break_tag5 = 0
  while break_tag5 == 0:
   modify_input = raw_input ("please input your modify item:").strip ()
   if len (modify_input) == 0:
    continue
   elif modify_input == 'quit':
    break
   content_modify = file (path, 'a+')
   modify_line = content_modify.readlines ()
   modata = list (modify_line)
   for i in modata:
    if modify_input in i:
     ms = modata.index (i)#獲取輸入變量的最終列表定位
     print i
     mosure = raw_input ("Are you sure to change this user ? (yes/no):").strip ()
     if len (mosure) == 0:
      continue
     elif mosure == 'yes':
      break_tag6 = 0
      while break_tag6 == 0:
       sureid_input = raw_input ("please input you will change this user id: ").strip ()
       if len(sureid_input) == 0:
        continue
       elif sureid_input == 'quit':
        break
       surename_input = raw_input ("please input you will change this user name:").strip ()
       if len(surename_input) == 0:
        continue
       elif surename_input == 'quit':
        sureid_input = None #此處賦空值,為了防止中途退出,而出現(xiàn)個(gè)別寫(xiě)入
        surename_input = None
        break
       sureage_input = raw_input ("please input you will change this user age:").strip ()
       if len(sureage_input) == 0:
        continue
       elif sureage_input == 'quit':
        sureid_input = None
        surename_input = None
        sureage_input = None
        break
       suredep_input = raw_input ("please input you will change this user department:").strip ()
       if len(suredep_input) == 0:
        continue
       elif suredep_input == 'quit':
        sureid_input = None
        surename_input = None
        sureage_input = None
        suredep_input = None
        break
       surephone_input = raw_input ("please input you will change this user phone:").strip ()
       if len(surephone_input) == 0:
        continue
       elif surephone_input == 'quit':
        sureid_input = None
        surename_input = None
        sureage_input = None
        suredep_input = None
        surephone_input = None
        break
       later_sure = [sureid_input, '\t', surename_input, '\t\t', sureage_input, '\t', suredep_input,'\t', surephone_input, '\n']#將上面的值放入列表
       del modata[ms] #當(dāng)整個(gè)輸入完成以后再進(jìn)行刪除,防止中途退出未完成狀體的刪除。
       modata_one = modata
       content_modify.close () #這里還是使用了刪除、轉(zhuǎn)存、重新寫(xiě)入的原理
       content_modify_list = file (path, 'w+')
       content_modify_list.writelines (modata_one)
       content_modify_list.close ()
       content_modify_list_one = file (path, 'a+')
       content_modify_list_one.writelines (later_sure)
       content_modify_list_one.close ()
       break
     elif mosure == 'quit' or 'no':
      break
 elif int (select_input) == 5:
  print("Thank you for use this employee system, write by franzhang!")
  sys.exit()

employee_list.txt:

更多學(xué)習(xí)資料請(qǐng)關(guān)注專(zhuān)題《管理系統(tǒng)開(kāi)發(fā)》。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python中Anaconda3 安裝gdal庫(kù)的方法

    Python中Anaconda3 安裝gdal庫(kù)的方法

    這篇文章主要介紹了Python中Anaconda3 安裝gdal庫(kù)的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-04-04
  • python裝飾器實(shí)現(xiàn)對(duì)異常代碼出現(xiàn)進(jìn)行自動(dòng)監(jiān)控的實(shí)現(xiàn)方法

    python裝飾器實(shí)現(xiàn)對(duì)異常代碼出現(xiàn)進(jìn)行自動(dòng)監(jiān)控的實(shí)現(xiàn)方法

    這篇文章主要介紹了python裝飾器實(shí)現(xiàn)對(duì)異常代碼出現(xiàn)進(jìn)行自動(dòng)監(jiān)控的實(shí)現(xiàn)方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-09-09
  • 詳解Python OpenCV圖像分割算法的實(shí)現(xiàn)

    詳解Python OpenCV圖像分割算法的實(shí)現(xiàn)

    圖像分割是指根據(jù)灰度、色彩、空間紋理、幾何形狀等特征把圖像劃分成若干個(gè)互不相交的區(qū)域。本文就來(lái)和大家聊聊OpenCV的圖像分割算法及基于輪廓的字符分離,感興趣的可以了解一下
    2022-08-08
  • Python中虛擬環(huán)境依賴(lài)問(wèn)題的解決方案詳解

    Python中虛擬環(huán)境依賴(lài)問(wèn)題的解決方案詳解

    在Python開(kāi)發(fā)中,虛擬環(huán)境和依賴(lài)管理是必不可少的工具,本文將以一個(gè)實(shí)際案例為基礎(chǔ),詳細(xì)分析如何解決Python虛擬環(huán)境中的依賴(lài)問(wèn)題,希望對(duì)大家有所幫助
    2025-03-03
  • Python實(shí)現(xiàn)FIFO緩存置換算法

    Python實(shí)現(xiàn)FIFO緩存置換算法

    這篇文章主要為大家詳細(xì)介紹了Python實(shí)現(xiàn)FIFO(先進(jìn)先出)緩存置換算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • 使用Python操作文件系統(tǒng)的方法

    使用Python操作文件系統(tǒng)的方法

    Python提供了許多內(nèi)置庫(kù)來(lái)處理文件系統(tǒng),如os、shutil和pathlib等,這些庫(kù)可以幫助你創(chuàng)建、刪除、讀取、寫(xiě)入文件和目錄,這篇文章主要介紹了使用Python操作文件系統(tǒng),需要的朋友可以參考下
    2023-07-07
  • Python?使用?pyc?解決明文密鑰問(wèn)題記錄

    Python?使用?pyc?解決明文密鑰問(wèn)題記錄

    pyc 是 Python 經(jīng)過(guò) compile 后的文件類(lèi)型,一段 Python 代碼執(zhí)行前會(huì)先將 .py 文件編譯成 .pyc 文件它是一種字節(jié)碼 byte code,然后由 Python 虛擬機(jī)執(zhí)行,這篇文章主要介紹了Python使用pyc解決明文密鑰問(wèn)題,需要的朋友可以參考下
    2023-07-07
  • Python3視頻轉(zhuǎn)字符動(dòng)畫(huà)的實(shí)例代碼

    Python3視頻轉(zhuǎn)字符動(dòng)畫(huà)的實(shí)例代碼

    這篇文章主要介紹了Python3視頻轉(zhuǎn)字符動(dòng)畫(huà)的實(shí)例代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-08-08
  • 9種python web 程序的部署方式小結(jié)

    9種python web 程序的部署方式小結(jié)

    python有很多web 開(kāi)發(fā)框架,代碼寫(xiě)完了,部署上線是個(gè)大事,通常來(lái)說(shuō),web應(yīng)用一般是三層結(jié)構(gòu)web server ---->application -----> DB server
    2014-06-06
  • python安裝后的目錄在哪里

    python安裝后的目錄在哪里

    在本篇內(nèi)容里小編給各位分享的是關(guān)于python安裝后的目錄位置的知識(shí)點(diǎn)內(nèi)容,需要的朋友們可以學(xué)習(xí)下。
    2020-06-06

最新評(píng)論

元阳县| 沙雅县| 富顺县| 大丰市| 湄潭县| 灵川县| 浦县| 凤凰县| 普宁市| 交城县| 承德县| 仲巴县| 宁蒗| 廉江市| 永登县| 米林县| 博兴县| 宁国市| 芦溪县| 奇台县| 渝北区| 从江县| 壤塘县| 新营市| 无棣县| 肇州县| 湄潭县| 汤原县| 阿克苏市| 阳信县| 宜黄县| 岳阳市| 淮阳县| 元氏县| 广州市| 建湖县| 宾川县| 虎林市| 新晃| 定日县| 临桂县|