使用_thread多线程模块ping主机代码 探测一个C段内1-254的主机是否存活,如果出现TTL则表示存活。 #!/usr/bin/env python # -*- coding: utf-8 -*- import _thread import subprocess import time def ping_check(ip): check = subprocess.getoutput('ping' + ' ' + ip)