首页 > 其他 > 详细

excle转list

时间:2020-02-16 17:07:57      阅读:56      评论:0      收藏:0      [点我收藏+]
import xlrd
def read_exlce(excelFile,index=0):
    read=xlrd.open_workbook(filename=excelFile)
    sheet=read.sheets() #读取所有sheet表
    curSheet=sheet[index]#读取指定的sheet表

    return curSheet

def exlce_to_list(curSheet):#一个sheet转为一个二维数组
    rows=curSheet.nrows
    cols=curSheet.ncols
    list=[]
    for row in range(rows):
        list2=[]
        for col in range(cols):
            list2.append(curSheet.cell(row,col))
        list.append(list2)
    return list

if __name__==__main__:
    sheet=read_exlce("D:\jodie\jodiepy\data_drive\date.xlsx")
    list=exlce_to_list(sheet)
    print(list)

 

excle转list

原文:https://www.cnblogs.com/jodie2019/p/12317178.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!