python">#网上代码
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
标签:python