1 import xlrd 2 book = xlrd.open_workbook('app_student.xls') 3 sheet = book.sheet_by_index(0) 4 # sheet2 = book.sheet_by_name('shee1') 5 # print(sheet.cell(0,0).value) #指定sheet頁里面行和lie獲取數據 6 # print(sheet.cell(1,0).value) #指定sheet頁里面行和lie獲取數據 7 # print(sheet.row_values(0)) #這個獲取到第幾行的內容 8 # print(sheet.row_values(1)) #這個獲取到第幾行的內容 9 # print(sheet.nrows) #獲取到excel里面總共有多少行 10 for i in range(sheet.nrows): #循環獲取到每行數據 11 print(sheet.row_values(i)) 12 #print(sheet.ncols) #總共多少列 13 #print(sheet.col_values(0)) #取第幾列的數據
?