python處理excel

首先你得安裝xrld模塊,到官網安裝下就可以了。

import xlrd
import sys
import xdrlib
import fun1
import string
xlsfile=r'E:\滲透測試2016\滲透資料\00-18.xlsx'  #get file
data=xlrd.open_workbook(xlsfile) #get object
sheet_name=data.sheet_names()[0]  #get sheet name  !!sheet is table you know?
print sheet_name
sheet1=data.sheet_by_name(sheet_name) #get table by name
sheet0=data.sheet_by_index(0) #use index to get sheet object
nrows=sheet1.nrows     #row count
ncols=sheet1.ncols     #col count
col_data=sheet1.col_values(0)       #get one col value
row_data=sheet1.col_values(0)    #get one row value
print 'ok' 
print 'finished'


發佈了55 篇原創文章 · 獲贊 67 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章