【Python】使用python openpyxl读取或写入某列数据

from openpyxl import load_workbook

wb = load_workbook('test.xlsx')
ws = wb['sheet1']

# 读取第 G 列数据不包括第一行
data = [cell.value for cell in ws['G'] if cell.row != 1]

# 向第三列存入数据
for index, item in enumerate(data):
    cell = ws.cell(row = index+2, column=3)
    cell.value = item

wb.save('test.xlsx')

你可能感兴趣的:(Python,python,数学建模,开发语言)