对比list的处理速度,list处理速度,#网上代码def ope
文章由Byrx.net分享于2019-03-23 05:03:28
对比list的处理速度,list处理速度,#网上代码def ope
#网上代码def open_httptxt(): #打开TXT文本写入数组 st=time.clock() try: passlist = [] list_passlist=[] xxx = file('http.txt', 'r') for xxx_line in xxx.readlines(): #past.append(xxx_line) passlist.append(xxx_line) xxx.close() for i in passlist: #python 列表去重 if i not in list_passlist: list_passlist.append(i) E = 0 #得到list的第一个元素 while E < len(list_passlist): #print list_passlist[E] past.append(list_passlist[E]) #添加到数组里 E = E + 1 except: return 0 print 'open_http ' +str(time.clock()-st)#自己写的函数def path_http(): st=time.clock() f=open('http.txt','r') tlst=f.readlines() past = {}.fromkeys(tlst).keys() #去掉重复 #past = list(set(tlst)) print 'my def path_http ' + str(time.clock()-st) f.close() return past
评论关闭