Lesson eight
excel表格:
库 xlrd
读 写
1,添加
2,查询
3,修改
3,删除
pyecharts(绘图)
#读取(查询):
import xlrd
from xlutils.copy import copy
path = “workbook1.xlsx”
book = xlrd.open_workbook(path)
sheet = book.sheet_by_index(0)
sheet = book.sheet_by_name(“Sheet1”)
print(sheet.cell(2,2).value)
print(sheet.nrows,sheet.ncols)
for i in range(0,sheet.nrows):
for j in range(0,sheet.ncols):
print(sheet.cell(i,j).value,end=" ")
print()
#增加:
import xlrd
path = “workbook1.xlsx”
from xlutils.copy import copy
book = xlrd.open_workbook(path)
sheet = book.sheet_by_index(0)
nrows = sheet.nrows
book_copy = copy(book)
sheet_copy = book_copy.get_sheet(0)
data = [‘321356’,‘565’,‘女’,‘阿文’,‘19’]
for i in range(0,len(data),1):
sheet_copy.write(nrows,i,data[i])
book_copy.save(‘workbook1.xlsx’)
1948

被折叠的 条评论
为什么被折叠?



