from xlutils.copy import copy
import xlrd
import os
def write_append(file_name):
values = ['张三','男',22]
r_xls = xlrd.open_workbook(file_name) #打开Excel文件读取数据
r_sheet = r_xls.sheet_by_index(0) #通过索引顺序获取
rows = r_sheet.nrows #获取行数
w_xls = copy(r_xls)
sheet_write = w_xls.get_sheet(0)
for i in range(0, len(values)):
sheet_write.write(rows, i, values[i])
w_xls.save(file_name)
if __name__ == "__main__":
write_append("po.xls")
python Excel追加数据
最新推荐文章于 2024-10-03 22:54:30 发布