import openpyxl filename = 'aaa.xlsx' wb = openpyxl.load_workbook(filename) # 加载表格 wb.save("aaa.xlsx") sh_name = wb.sheetnames # 获取所有sheet sh = wb[sh_name[0]] sh.title = "dddd" # 修改第一个sheet名为dddd wb.close()
# mac修改后,肉眼检查没反应,但是代码检测已经修改