python在windows下实现ping操作并接收返回信息的代码
作者:互联网
把写代码过程中较好的一些代码做个备份,如下的代码是关于python在windows下实现ping操作并接收返回信息的代码。
import subprocess
import re
p = subprocess.Popen([“ping.exe”, ‘google.com’],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
shell = True)
out = p.stdout.read()
regex = re.compile(“Minimum = (d+)ms, Maximum = (d+)ms, Average = (d+)ms”, re.IGNORECASE)
print regex.findall(out)
标签:re,python,代码,ping,subprocess,PIPE,windows,ms 来源: https://blog.csdn.net/Warren891/article/details/122373629