首页 > 其他分享 >——————测试——————测试————————

——————测试——————测试————————

时间:2022-12-01 11:57:18浏览次数:24  
标签:network ip IProute netmask 测试 print txt

from netaddr import IPNetwork

#读取txt文件每行合并字符串
with open('D:/Deve/CNaddress.txt','r',encoding='utf-8') as f:
    for line in f.readlines():
        ip_network = IPNetwork(line)#识别IP/掩码
        ip_netmask=(str(ip_network.network))+' '+str(ip_network.netmask)#字符串形式输出IP+掩码
        IProute = 'ip route ' + ip_netmask + ' FastEthernet0/0 222.71.222.121 name CN\n'#字符串合并,修改 <interface> <address>
        #print (ip_network)

#写入txt文件
        dic = open("D:/Deve/CN_CISCO.txt", "a")
        for i in IProute:
            dic.write("".join(i))
        print (IProute)
print ('done')

 

标签:network,ip,IProute,netmask,测试,print,txt
From: https://www.cnblogs.com/c0ldzera/p/16940985.html

相关文章