python 生成器 yield

        def __xlsx2tuples(self, path):

        '''ganerator tuples from xlsx file

        '''

        wb = load_workbook(path)

        sheets = wb.get_sheet_names()

        for sheet in sheets:

            ws = wb.get_sheet_by_name(sheet)

            for row in ws.rows:

                row_list = []

                for cell in row:

                    row_list.append(cell.value)

                yield tuple(row_list)

相关推荐