__VERSION__ = ‘1.0‘ import xlrd as rd; import xlwt as wt; import os; class ExcelOperation(): def readExcel(self): excelDir=os.getcwd()+"\\"+"2222.xls"; book=rd.open_workbook(excelDir); sheet1=book.sheets()[0]; for i in range(sheet1.nrows): for j in range(sheet1.ncols): print(sheet1.cell(i,j).value) def writeExcel(self): "" "" if __name__=="__main__": obj=ExcelOperation() obj.readExcel()
import unittest import OpExcel as EO; class Test(unittest.TestCase): def testName(self): testEO=EO.ExcelOperation(); testEO.readExcel() if __name__ == "__main__": #import sys;sys.argv = [‘‘, ‘Test.testName‘] unittest.main()
时间: 2024-11-08 22:39:53