描述+ip

 1 #dis ip int bri | inc up 放入1.txt dis int des | inc up 放入2.txt 主接口排序标准放4.txt接口都以GE8/1/0形式
 2 with open('1.txt',encoding='UTF8') as f_1,\
 3     open('2.txt',encoding='UTF8') as f_2,\
 4     open('3.txt','w') as f_3,\
 5     open('4.txt',encoding='UTF8') as f_4,\
 6     open('5.txt','w') as f_5:
 7     list_1,list_2,list_3 = [],[],[]
 8     for f11 in f_1:
 9         list_1.append(f11)
10     for f22 in f_2:
11         list_2.append(f22)
12     list_22 = list_2.copy()
13     for i in list_1:
14         a = i.split()[0]
15         for t in list_2:
16             if t.startswith(f'{a}'):
17                 b = t.replace(f'{a}',f'{i.strip()}',1)
18                 f_3.write(b)
19                 list_3.append(b)
20                 del list_22[list_22.index(t)]
21                 i,t = '',''
22                 break
23         if i :
24             f_3.write(i.strip()+'\n')
25             list_3.append(i.strip()+'\n')
26     f_3.writelines(list_22)
27     list_3.extend(list_22)
28     for f44 in f_4:
29         for c in list_3:
30             cc = c.split()[0]
31             if f44.strip() == cc.split('.')[0].replace('(10G)',''):
32                 d = f44.strip() + '   '+ c
33                 f_5.write(d)
34                 d = ' '
35                 continue
36             else :
37                 pass

 

posted @ 2020-07-14 15:51  renke123  阅读(166)  评论(0编辑  收藏  举报