import sys import xlrd import traceback def ReadData(FileName): try: workBook = xlrd.open_workbook(FileName) sheetsList = workBook.sheet_names() sheetNum = len(sheetsList) for i in range(sheetNum): readName = sheetsList[i] #para = [‘sheet%s‘ %i] sheet = workBook.sheet_by_index(i) print(readName+‘:\n‘) for i in range(sheet.nrows): rows = sheet.row_values(i) print(rows) except: traceback.print_exc() if __name__ == ‘__main__‘ : ReadData(‘demo1.xlsx‘)
时间: 2024-11-07 06:30:25