首页 > 代码库 > python之Excel操作

python之Excel操作

#coding:utf-8__author__ = ‘similarface‘import xlrdbook=xlrd.open_workbook(‘/Users/similarface/Downloads/0808-10个ET/0808-10个ET.xlsx‘)#遍历所有的sheetsfor sheet in book.sheets():    print(sheet.name)    #print sheetbook = xlrd.open_workbook(‘/Users/similarface/Downloads/0808-10个ET/0808-10个ET.xlsx‘)#获取指定的sheetsheet = book.sheet_by_name(‘Sheet1‘)#获取sheet的行数print sheet.nrows#遍历sheet的所有行号for i in range(sheet.nrows):    print i#遍历sheet的所有行for i in range(sheet.nrows):    print sheet.row_values(i)#遍历所以的行,for i in range(sheet.nrows):    row=sheet.row_values(i)    #遍历行的所有列的值    for cell in row:        print cell

  

python之Excel操作