读写 Excel读 Excel1234567import xlrddef read_file('file.xlsx'):data = xlrd.open_workbook(url)table = data.sheets()[0] # 打开第一张表nrows = table.nrows # 获取表的行数for i in range(nrows): # 循环逐行打印 print(table.row_values(i)[1:])写 Excel1234567891011121314import xlwtdata = xlrd.open_workbook('excelFile.xls')excel = copy(data) #使用wlrd的方法获取已有的的行数rows = data.sheet()[num].nrows #获得要操作的sheettable = excel.get_sheet(num) for value in n: #xlwt的写方法,参数为行,列,值,行 table.write(rows,num1,value) num1 = num1+1 excel.save(name)