python 读取excel表格某列数据
1.使用python包栈为openpyxl
2.多说无益,直接上代码
3.读取两个excel某列数据进行对比取交集
import openpyxl def get_entitydi(): workbook = openpyxl.load_workbook("2021年行业返佣.xlsx") book_sheet = workbook["Sheet1"] row_all = book_sheet.rows data = [] for row in list(row_all)[2:]: coinsh = [] for value in row: coinsh.append(value.value) data.append(coinsh) entity_list = [] for parment in data: entity = parment[7] entity_list.append(entity) return entity_list def get_data(): workbook = openpyxl.load_workbook("有效时间表.xlsx") book_sheet = workbook["Sheet1"] row_all = book_sheet.rows data = [] for row in list(row_all)[1:]: coinsh = [] for value in row: coinsh.append(value.value) data.append(coinsh) entity_list2 = [] for parment in data: entity = parment[1] entity_list2.append(entity) return entity_list2 def mach_two(): mach_list = [] entity_list = get_entitydi() entity_list2 = get_data() for entity in entity_list: if entity in entity_list2: mach_list.append(entity) return mach_list if __name__ == '__main__': data = mach_two() print(data)