标签:print 字典 append div 提取 分割 一个 return pen
1 myseq = ‘‘‘[a:1,b:2,c:3] 2 [a:3,b:3,c:8] 3 [a:7,c:2:m:7,r:4] 4 [a:2,c:4:m:6,r:4] 5 [a:3,b:2,c:7,o:5]‘‘‘ 6 7 def eve(i): 8 evest=‘‘ 9 for x in range(0,len(i),2): 10 evest+=i[x] 11 return evest 12 myseq=myseq.split(‘\n‘) 13 lt=[] 14 for i in myseq: 15 lt.append(eve(i.replace(‘[‘,‘‘).replace(‘]‘,‘‘).replace(‘:‘,‘‘).replace(‘,‘,‘‘))) 16 17 ##print(lt) 18 l1,l2=[],[] 19 for i in range(len(lt)): 20 if lt[i] not in l2: 21 l2.append(lt[i]) 22 l1.append(myseq[i]) 23 ##print(l2) 24 print(l1)
运行结果:
[‘[a:1,b:2,c:3]‘, ‘[a:7,c:2:m:7,r:4]‘, ‘[a:3,b:2,c:7,o:5]‘]
标签:print 字典 append div 提取 分割 一个 return pen
原文地址:https://www.cnblogs.com/lovejh/p/9235930.html