小白学python。
# -*- coding:utf-8 -*- """ Python 3.7 作者:孙敏 日期:2022年02月01日 """ from openpyxl import Workbook # 创建excel文件 wb = Workbook() ws = wb.active print(ws) for sheet in wb: print(sheet.title) sheet.title = 'salary luffy' print(sheet.title) wb.save("文件夹.xlsx")#保存文件 # 打开已有的文件 from openpyxl import load_workbook wb2 = load_workbook('D:\python\\test\文件夹.xlsx') sheet['c5'] = "hello " wb.save("文件夹.xlsx")#保存文件