久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      Python自動化實踐之篩選簡歷

      本篇文章給大家?guī)砹岁P(guān)于python的相關(guān)知識,其中主要介紹了關(guān)于簡歷篩選的相關(guān)問題,包括了定義 ReadDoc 類用以讀取 word 文件以及定義 search_word 函數(shù)用以篩選的相關(guān)內(nèi)容,下面一起來看一下,希望對大家有幫助。

      Python自動化實踐之篩選簡歷

      推薦學(xué)習(xí):python視頻教程

      簡歷篩選

      簡歷相關(guān)信息如下:


      Python自動化實踐之篩選簡歷


      定義 ReadDoc 類用以讀取 word 文件

      已知條件:

      想要查找包含指定關(guān)鍵字的簡歷(比如 Python、Java)


      實現(xiàn)思路:

      批量讀取每一個 word 文件(通過 glob 獲取 word 信息),將他們的所有可讀內(nèi)容獲取,并通過關(guān)鍵字方式篩選,拿到目標(biāo)簡歷地址。


      這里有個需要注意的地方就是,并不是所有的 "簡歷" 都是以段落的形式呈現(xiàn)的,比如從 "獵聘" 網(wǎng)下載下來的簡歷就是 "表格形式" 的,而 "boss" 上下載的簡歷就是 "段落形式" 的,這里再進(jìn)行讀取的時候需要注意下,我們做的演示腳本練習(xí)就是 "表格形式" 的。


      這里的話,我們就可以專門定義一個 "ReadDoc" 的類,里面定義兩個函數(shù),分別用于讀取 "段落" 和 "表格" 。

      實操案例腳本如下:

      # coding:utf-8from docx import Documentclass ReadDoc(object):              # 定義一個 ReadDoc ,用以讀取 word 文件     def __init__(self, path):       # 構(gòu)造函數(shù)默認(rèn)傳入讀取 word 文件的路徑         self.doc = Document(path)         self.p_text = ''         self.table_text = ''          self.get_para()         self.get_table()       def get_para(self):             # 定義 get_para 函數(shù)用以讀取 word 文件的段落         for p in self.doc.paragraphs:             self.p_text += p.text + 'n'    # 讀取的段落內(nèi)容進(jìn)行換行         print(self.p_text)       def get_table(self):            # 定義 get_table 函數(shù)循環(huán)讀取表格內(nèi)容         for table in self.doc.tables:             for row in table.rows:                 _cell_str = ''      # 獲取每一行的完整信息                 for cell in row.cells:                     _cell_str += cell.text + ','    # 每一行加一個 "," 隔開                 self.table_text += _cell_str + 'n'     # 讀取的表格內(nèi)容進(jìn)行換行         print(self.table_text)if __name__ == '__main__':     path = glob.os.path.join(glob.os.getcwd(), 'test_file/簡歷1.docx')     doc = ReadDoc(path)     print(doc)

      看一下 ReadDoc 類的運(yùn)行結(jié)果


      Python自動化實踐之篩選簡歷


      定義 search_word 函數(shù)用以篩選 word 文件內(nèi)容符合想要的簡歷

      OK,上文已經(jīng)成功讀取了簡歷的 word 文檔,接下來我們要將讀取到的內(nèi)容通過帥選關(guān)鍵字信息的方式,過濾出包含有關(guān)鍵字的簡歷。

      實操案例腳本如下:

      # coding:utf-8import globfrom docx import Documentclass ReadDoc(object):              # 定義一個 ReadDoc ,用以讀取 word 文件     def __init__(self, path):       # 構(gòu)造函數(shù)默認(rèn)傳入讀取 word 文件的路徑         self.doc = Document(path)         self.p_text = ''         self.table_text = ''          self.get_para()         self.get_table()       def get_para(self):             # 定義 get_para 函數(shù)用以讀取 word 文件的段落         for p in self.doc.paragraphs:             self.p_text += p.text + 'n'    # 讀取的段落內(nèi)容進(jìn)行換行         # print(self.p_text)        # 調(diào)試打印輸出 word 文件的段落內(nèi)容       def get_table(self):            # 定義 get_table 函數(shù)循環(huán)讀取表格內(nèi)容         for table in self.doc.tables:             for row in table.rows:                 _cell_str = ''      # 獲取每一行的完整信息                 for cell in row.cells:                     _cell_str += cell.text + ','    # 每一行加一個 "," 隔開                 self.table_text += _cell_str + 'n'     # 讀取的表格內(nèi)容進(jìn)行換行         # print(self.table_text)    # 調(diào)試打印輸出 word 文件的表格內(nèi)容def search_word(path, targets):     # 定義 search_word 用以篩選符合內(nèi)容的簡歷;傳入 path 與 targets(targets 為列表)     result = glob.glob(path)     final_result = []               # 定義一個空列表,用以后續(xù)存儲文件的信息      for i in result:             # for 循環(huán)獲取 result 內(nèi)容          isuse = True                # 是否可用          if glob.os.path.isfile(i):       # 判斷是否是文件             if i.endswith('.docx'):      # 判斷文件后綴是否是 "docx" ,若是,則利用 ReadDoc類 實例化該文件對象                 doc = ReadDoc(i)                 p_text = doc.p_text         # 獲取 word 文件內(nèi)容                 table_text = doc.table_text                 all_text = p_text + table_text                for target in targets:      # for 循環(huán)判斷關(guān)鍵字信息內(nèi)容是否存在                     if target not in all_text:                         isuse = False                         break                  if not isuse:                     continue                 final_result.append(i)     return final_resultif __name__ == '__main__':     path = glob.os.path.join(glob.os.getcwd(), '*')     result = search_word(path, ['python', 'golang', 'react', '埋點'])      # 埋點是為了演示效果,故意在 "簡歷1.docx" 加上的     print(result)

      運(yùn)行結(jié)果如下:


      Python自動化實踐之篩選簡歷


      推薦學(xué)習(xí):python視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號