pandas——向已经存在的excel数据写入data

from xlutils.copy import copy
import xlrd

# 加载已存在的xls
old_workbook = xlrd.open_workbook('guoshun.xlsx')

# 将已存在的excel拷贝进新的excel
new_workbook = copy(old_workbook)

# 获取sheet
new_worksheet = new_workbook.get_sheet(0)
data_set=['100','10','0.1000','100','100']
# 写入数据
row = 5  # 已存在文件中的数据行数
for data in data_set:
    new_worksheet.write(row, 0, data)
    new_worksheet.write(row, 1, data)
    row += 1

# 将新写入的数据保存
new_workbook.save('guoshun.xlsx')

 

posted @ 2021-03-15 22:02  朵朵奇fa  阅读(2128)  评论(0编辑  收藏  举报