1 #python3.9.1 2 # #1.逐行读取文件返回list 3 # def getList(dir,fileNm): 4 # list = [] 5 # fl = open(dir+"\"+fileNm) 6 # line = fl.readline() 7 # while line: 8 # line = line.strip(' ') 9 # list.append(line) 10 # line = fl.readline() 11 # fl.close() 12 # return list 13 14 # #2.python操作excel 15 # import openpyxl 16 # workdir = r"" 17 # filenm = "" 18 # wb = openpyxl.load_workbook(filenm=workdir+"\"+filenm) 19 # sh = wb[''] 20 # cell_value = sh[''].value 21 22 # #3.list比较 23 # #list2没有 24 # result1 = set(list1).difference(set(list2)) 25 # #list1没有 26 # result2 = set(list2).difference(set(list1)) 27 28 ##4.写入文件 29 # with open(workDir+"\"+f,'w') as file_object: 30 # file_object.write(content+" ") 31 32 # #5.list去重,会改变顺序 33 # list(set(lists)) 34 35 # #6.list去重,不改变顺序 36 # def distinctList(list1): 37 # list2 = [] 38 # for i in list1: 39 # if i not in list2: 40 # list2.append(i) 41 # return list2