📜  python ping ip地址 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:08.790000             🧑  作者: Mango

代码示例1
import os

ip_list = ['8.8.8.8']
for ip in ip_list:
    response = os.popen(f"ping {ip}").read()
    if "Received = 4" in response:
        print(f"UP {ip} Ping Successful")
    else:
        print(f"DOWN {ip} Ping Unsuccessful")