# -*- coding: utf-8 -*- # 安装 pip install pypiwin32 导入win32com import os from win32com.client import Dispatch import win32com.client path = os.getcwd() old_file_path = path + '\\表格.xls' new_file_path = path + '\\表格.xlsx' excel = win32com.client.dynamic.Dispatch('Excel.Application') wb = excel.Workbooks.Open(old_file_path) wb.SaveAs(new_file_path, 51) wb.Close() excel.Quit()