1. 程式人生 > >list 去重

list 去重

.cn port fin lis mpi == += while dal

import re
lst = [‘http://img3m9.ddimg.cn/53/33/1354578839-1_x.jpg‘,
‘http://img3m9.ddimg.cn/63/34/1354579839-1_x.jpg‘,
‘http://img3m9.ddimg.cn/70/31/1354580539-1_x.jpg‘,
‘http://img3m9.ddimg.cn/48/14/1354578339-1_x.jpg‘,
‘http://img3m9.ddimg.cn/35/35/1372811849-1_x.jpg‘,
‘http://img3m9.ddimg.cn/60/30/1354579539-1_x.jpg‘,
‘http://img3m9.ddimg.cn/29/27/1372811249-1_x.jpg‘,
‘http://img3m7.ddimg.cn/47/34/1297859357-1_b_1.jpg‘,
‘http://img3m7.ddimg.cn/73/7/1297861957-1_x.jpg‘,
‘http://img3m7.ddimg.cn/67/36/1297861357-1_x.jpg‘,
‘http://img3m7.ddimg.cn/51/27/1297859757-1_x.jpg‘,
‘http://img3m7.ddimg.cn/71/29/1297861757-1_x.jpg‘]
i=0
while i < len(lst):
pat = ‘http://.*?/.*?/.*?/([0-9]{5})‘
data = re.compile(pat).findall(lst[i])
k=0
j=0
while j<len(lst):
data1 = re.compile(pat).findall(lst[j])
if (data == data1):
print(lst[j])
k += 1
if k>1 :
lst.pop(j)
j=j-1
j+=1
i += 1
print(‘- ‘ * 30)
print(lst)

list 去重