标签:for int not lin 去除 close str __name__ adp
批量C段转换为192.168.1.1-192.168.1.255
import IPy def ipcToips(): readPath=‘ip_c.txt‘ writePath=‘ips.txt‘ writeFile=open(writePath,‘w‘) with open(readPath,‘r‘) as f: for line in f: ip_c=line.strip(‘\n‘) ip = IPy.IP(ip_c) # print ip.len() for line in ip: # 保留1921168.1.1-255,去除192.168.1.0 if (‘.0‘) not in str(line).strip(‘\n‘): writeFile.write(str(line)+‘\n‘) writeFile.close() if __name__ == ‘__main__‘: ipcToips()
标签:for int not lin 去除 close str __name__ adp
原文地址:https://www.cnblogs.com/oliver-yt/p/12986904.html