python使用xlrd模塊讀取xlsx文件中的ip方法

今天小編就爲大家分享一篇python使用xlrd模塊讀取xlsx文件中的ip方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

程序中經常需要使用excel文件,批量讀取文件中的數據

python讀取excel文件可以使用xlrd模塊

pip install xlrd安裝模塊

示例:

#coding=utf8

import xlrd
from os import path
import sys

filename='ip.xlsx'
if not path.isfile(filename):
 print "err: not exists or not file ip.xlsx "
 sys.exit()

getfile=xlrd.open_workbook(filename)
table=getfile.sheet_by_index(0)
rows=table.nrows
#cols=table.ncols 若有多列,再加一層for循環
for i in xrange(rows):
 cell_vlaues=table.cell_value(i,0)
 print cell_vlaues

以上這篇python使用xlrd模塊讀取xlsx文件中的ip方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持神馬文庫。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章