subprocess threading time re ip_num = list_ping_result = [] PingThread(threading.Thread): (str_ipsleep_timeg_list_p_r): threading.Thread.() .sleep_time = sleep_time .str_ip = str_ip .list_p_r = g_list_p_r (): time.sleep(.sleep_time) ftp_sub = subprocess.Popen(% .str_ip=subprocess.PIPE=subprocess.PIPE=) ret = ftp_sub.stdout.read() str_ret = ret.decode() ret_s = re.search(str_ret) ret_s: .list_p_r.append((.str_ip)) : .list_p_r.append((.str_ip)) (toupe_str): str_val = toupe_str[] ret_group = re.match(str_val[::-]) str_ret = ret_group.group() (str_ret[::-]) thread_id = [] i (ip_num): thread_id.append() thread_id[i] = PingThread(% i(i / )list_ping_result) thread_id[i].start() (i=) : (list_ping_result) >= ip_num: list_ping_result.sort(=cmp_s) i list_ping_result: (i)
结果如下:
可以通过平命令进行验证:
使用上图的28和29ip进行测试: