那麼我完全停留在閱讀excel表格(初學python)....我有3列在Excel表格中說(A
,B
和C
)與n
行數在他們每一個....所以我怎麼可能創建一個循環遍歷所有的行,直到它到達結束,並將內容寫入文本文件(.txt)....行數相同的所有3列....幫助請我用開拓的excel表在python中使用excel表格3.4
代碼:
import xlrd
workbook = xlrd.open_workbook('Book1.xlsx')
worksheet = workbook.sheet_by_name('Sheet1')
代碼使用:
num_rows = worksheet.nrows - 1
num_cells = worksheet.ncols - 1
curr_row = -1
while curr_row < num_rows:
curr_row += 1
row = worksheet.row(curr_row)
curr_cell = -1
while curr_cell < num_cells:
curr_cell += 1
cell_value = worksheet.cell_value(curr_row, curr_cell)
print (cell_value)
你似乎不具有超出打開紙嘗試新鮮事物? – wRAR 2014-09-04 05:02:57
@wRAR添加了我正在使用的代碼...但我不能夠(添加參數),我必須閱讀Excel表格中的特定表格... – Maxxie 2014-09-04 06:20:11