Python使用xlrd库读取Excel表格内容
import xlrd class modifyfilr(): def __init__(self): # 首先打开excel文件 self.xl = xlrd.open_workbook(r'S:\\Elements.xlsx') def file(self): xl = self.xl print(xl) sheets = xl.sheets()[0] print(sheets) # 最大行数 row = sheets.row_values(0) # print(row) rows = sheets.nrows # print(rows) # 最大列数 column = sheets.col_values(1) # print(column) columns = sheets.ncols # print(columns) #定义临时空列表,用于存放数据 temp_list = [] #循环次数为表的最大行数 for i in range(0,rows - 1): # print(sheets.col_values(i)) #循环表的所有行 for cell in sheets.row_values(i): #如果表格的值不为None ,添加到列表中 if cell is not None: temp_list.append(cell) print(temp_list) if __name__ == '__main__': modifyfilr = modifyfilr() modifyfilr.file()
#Python##打开Python的大门#
Python 文章被收录于专栏
Python由荷兰数学和计算机科学研究学会的吉多·范罗苏姆于1990年代初设计,作为一门叫做ABC语言的替代品。Python提供了高效的高级数据结构,还能简单有效地面向对象编程。Python语法和动态类型,以及解释型语言的本质,使它成为多数平台上写脚本和快速开发应用的编程语言,随着版本的不断更新和语言新功能的添加,逐渐被用于独立的、大型项目的开发
SHEIN希音公司福利 276人发布
