标签:主机 windows python 在线 import
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os,re
with open("ip.txt","w",encoding="utf-8") as f:
for i in range(20,30):
ip=os.popen("ping -n 1 192.168.72.%s"%i).read().strip()
f.write(ip)
with open("ip.txt",encoding="utf-8") as f_r,open("ip2.txt","w",encoding="utf-8") as f_w:
for i in f_r:
if "TTL" in i:
m = re.search("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", i)#用正则匹配IP
f_w.write("%s\n"%m.group())
标签:主机 windows python 在线 import
原文地址:http://9272317.blog.51cto.com/9262317/1768594