程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

About Python operation excel, xlwt, xlwd, the simplest operation introduction

編輯:Python

About use python Medium xlwt,xlrd The most basic understanding

excel Of index It's from 0 At the beginning

xlwt write in excel

Mainly used
xls = xlwt.Workbook() # Create a excle
sheet = xls.add_sheet(“sheet1”) # Create a sheet


Now you can operate ,sheet It's already created


sheet.write(row,col,“data”) # In the row That's ok col Column write data
xls.save(" Storage address ")

wlrd Read excle

It mainly includes
xls = xlrd.open_wordbook(“ File path ”) # Read excle
xls.sheet_names()[index] # Return all sheet , You can add [ index] Return the specified sheet
#sheet = sheet.
xls.sheet_by_name(“name”) # The return name is name Of sheet
xls.sheet_by_index(data) # Return ..

Return a column

#sheet1 = sheet_by_index(0)
shee1.row_values(n) # For the first n All the data of the row
sheet1.col_values(n) # For the first n All data of the column

Return a cell

shee1.cell(1,1).value() # return sheet1 Two rows and two columns of data
sheet1.cell_value(1,1) # ditto

sheet1.cell(1,1),ctype() # Get the properties of the cell


2020/10/7


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved