http://www.lfd.uci.edu/~gohlke/pythonlibs/
ctrl+F搜索下载openpyxl,下载后安装即可
1 #python3读写excel 2 3 from openpyxl import Workbook 4 from openpyxl import load_workbook 5 import openpyxl 6 7 #新建excel 8 wb2=openpyxl.Workbook() 9 wb2.save('test.xlsx') 10 print('新建成功') 11 12 #读取数据 13 wb1=openpyxl.load_workbook('data.xlsx') 14 wb2=openpyxl.load_workbook('test.xlsx') 15 sheets1=wb1.get_sheet_names()#获取sheet页 16 sheets2=wb2.get_sheet_names() 17 sheet1=wb1.get_sheet_by_name(sheets1[0]) 18 sheet2=wb2.get_sheet_by_name(sheets2[0]) 19 20 max_row=sheet1.max_row#最大行数 21 max_column=sheet1.max_column#最大列数 22 23 for m in range(1,max_row+1): 24 for n in range(97,97+max_column):#chr(97)='a' 25 n=chr(n)#ASCII字符 26 i='%s%d'%(n,m)#单元格编号 27 cell1=sheet1[i].value#获取data单元格数据 28 sheet2[i].value=cell1#赋值到test单元格 29 30 wb2.save('test.xlsx')#保存数据 31 wb1.close()#关闭excel 32 wb2.close()