• xlrd模块


    1、通过xlrd模块读取Excel每行的内容

    pyhton3安装xlrd模块:pip3 install xlrd

    1 import xlrd
    2 filepath='xxxxx.xlsx' # 文件路径
    3 sheet = xlrd.open_workbook(filepath) #获得sheet对象
    4 
    5 for sheet_name in sheet.sheet_names():
    6     sheet2 = sheet.sheet_by_name(sheet_name)
    7     for row in range(0,sheet2.nrows):
    8         rows = sheet2.row_values(row)
    9         print(rows)
    View Code
    sheet = xlrd.open_workbook(filepath)
    sheet.sheet_names()#获取Excel的所有的sheet的名字
    sheet._sheet_names #获取Excel的所有的sheet的名字
    sheet._sheet_list #获取sheet对象
    sheet2=sheet.sheet_by_name(sheet_name)通过sheet名称huozi
    sheet2.nrows
    sheet2.name
    sheet2.ncols
    1    sheet = xlrd.open_workbook(filepath)
    2     for sheet2 in sheet._sheet_list:
    3         for row in range(0,sheet2.nrows):
    4             rows = sheet2.row_values(row)
    5             print(rows)
    View Code
  • 相关阅读:
    Hive的架构和工作流程
    Hive的定义及搭建
    HBase API操作
    HBase相关概念简介
    HBase shell常用命令
    HBase的简介和搭建
    scrapy useragent
    scrapy settings
    scrapy中的request对象
    python语法
  • 原文地址:https://www.cnblogs.com/Ming-Hui/p/9379529.html
Copyright © 2020-2023  润新知