#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/10/17 14:41 # @Author : Sa.Song # @Desc : # @File : read_xls.py # @Software: PyCharm import sys from xlrd import open_workbook # xlrd用於讀取xld import xlwt # 用於寫入xls workbook = open_workbook(r'C:\Users\songsa\Desktop\maoyan_comment.xls') # 打開xls文件 sheet_name= workbook.sheet_names() # 打印全部sheet名稱,是個列表 sheet = workbook.sheet_by_index(0) # 根據sheet索引讀取sheet中的全部內容 sheet1= workbook.sheet_by_name('Sheet1') # 根據sheet名稱讀取sheet中的全部內容 print(sheet.name, sheet.nrows, sheet.ncols) # sheet的名稱、行數、列數 content = sheet.col_values(7) # 第六列內容 print(content)
想了解更多Python關於爬蟲、數據分析的內容,歡迎你們關注個人微信公衆號:悟道Pythonpython