import xlrd# 读取xls文件# 打开xls文件data = xlrd.open_workbook('x1.xls')print(type(data))# 获取表Sheet1table = data.sheet_by_name(u'Sheet1')print(type(table))# 获取行数据arr = table.row_values(0)print(arr)# 获取列数据arr2 = table.col_values(0)print(arr2)# 统计行数rows_count = table.nrowsprint(rows_count)# 统计列数cols_count = table.ncolsprint(cols_count)# 获取单元格的值v00 = table.cell(0, 0).valueprint(v00)import xlwt# 写入xls文件# 新建xls,并设置ascii编码workbook = xlwt.Workbook(encoding='ascii')# 新建sheet表worksheet = workbook.add_sheet('my sheet')# 向表中写入数据’中文汉字‘worksheet.write(0, 0, label='中文汉字')# 保存xls,并设置名称workbook.save('002.xls')