import xlwings as xw tfile="test.xlsx" newfile="new.xlsx" app = xw.App(visible=False, add_book=False) app.display_alerts = False app.screen_updating = False wb = app.books.open(tfile) ws = wb.sheets[0] ws2 = wb.sheets[1] ws.range("A1").value = 101 ws2.range("A1").value = 102 wb.sheets[1].delete() wb.save() wb.save(newfile) #这里另存为,习惯先复制模板可以用系统命令,感觉更快 cmd = 'copy ' + tfile + ' ' +newfile #不弹黑窗口 subprocess.call(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) wb.close() app.quit()