Python openpyxl 遍歷所有sheet 查找特定字符串的方法
如下所示:
from openpyxl import workbook from openpyxl import load_workbook from openpyxl import worksheet def find_false_in_sheet(sheet): for column in sheet.iter_cols(): for cell2 in column: if cell2.value is not None: # print cell2.value # print type(cell2.value) info2 = cell2.value.find('false') if info2 == 0: print cell2 print cell2.value def find_false_in_xlsx(file_name): print file_name wb = load_workbook(file_name) all_sheets = wb.get_sheet_names() print(all_sheets) for i in range(len(all_sheets)): sheet = wb.get_sheet_by_name(all_sheets[i]) print (sheet.title + ': max_row: ' + str(sheet.max_row) + ' max_column: ' + str(sheet.max_column)) find_false_in_sheet(sheet) # start find_false_in_xlsx("test.xlsx") # for row in sheet.iter_rows(): # for cell in row: # if cell.value is not None: # info = cell.value.find('BB') # if info == 0: # print cell.value
以上這篇Python openpyxl 遍歷所有sheet 查找特定字符串就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用python檢測(cè)主機(jī)存活端口及檢查存活主機(jī)
這篇文章主要介紹了使用python檢測(cè)主機(jī)存活端口及檢查存活主機(jī)的相關(guān)資料,需要的朋友可以參考下2015-10-10Pytorch Tensor基本數(shù)學(xué)運(yùn)算詳解
今天小編就為大家分享一篇Pytorch Tensor基本數(shù)學(xué)運(yùn)算詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-12-12在Python中使用swapCase()方法轉(zhuǎn)換大小寫的教程
這篇文章主要介紹了在Python中使用swapCase()方法轉(zhuǎn)換大小寫的教程,是Python入門中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-05-05Jmeter HTTPS接口測(cè)試證書(shū)導(dǎo)入過(guò)程圖解
這篇文章主要介紹了Jmeter HTTPS接口測(cè)試證書(shū)導(dǎo)入過(guò)程圖解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07Python爬蟲(chóng)實(shí)現(xiàn)抓取京東店鋪信息及下載圖片功能示例
這篇文章主要介紹了Python爬蟲(chóng)實(shí)現(xiàn)抓取京東店鋪信息及下載圖片功能,涉及Python頁(yè)面請(qǐng)求、響應(yīng)、解析等相關(guān)操作技巧,需要的朋友可以參考下2018-08-08基于python OpenCV實(shí)現(xiàn)動(dòng)態(tài)人臉檢測(cè)
這篇文章主要為大家詳細(xì)介紹了基于python OpenCV實(shí)現(xiàn)動(dòng)態(tài)人臉檢測(cè),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05Python干貨實(shí)戰(zhàn)之八音符醬小游戲全過(guò)程詳解
讀萬(wàn)卷書(shū)不如行萬(wàn)里路,只學(xué)書(shū)上的理論是遠(yuǎn)遠(yuǎn)不夠的,只有在實(shí)戰(zhàn)中才能獲得能力的提升,本篇文章手把手帶你用Python實(shí)現(xiàn)一個(gè)八音符醬小游戲,大家可以在過(guò)程中查缺補(bǔ)漏,提升水平2021-10-10