---
title: "python 生成器 yield"
author: "waveeee"
date: "2011-08-04T15:25:18Z"
tags: []
categories: ["移动开发"]
slug: "python-yield"
draft: false
lastmod: "2011-08-04T15:25:18Z"
id: 1140083
url: "https://waveeee.iteye.com/blog/1140083"
---

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)