#-*-Coding:utf-8-*-
Import OS
Import re
p = Os.popen (' ping 120.26.77.101 ')
out = P.read ()
Regex = Re.compile ("\XD7\XEE\XB6\XCC = (\d+) ms\xa3\xac\xd7\xee\xb3\xa4 = (\d+) ms\xa3\xac\xc6\xbd\xbe\xf9 = (\d+) MS", re . IGNORECASE)
All_result = Regex.findall (out)
min_time = Int (all_result[0][0])
max_time = Int (all_result[0][1])
avg_time = Int (all_result[0][2])
Print (' Shortest time: ' + str (min_time) + ' ms, ' + ' Maximum time: ' + str (max_time) + ' ms, ' + ' Average time: ' + str (avg_time) + ' MS ')
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)
Get the shortest, longest, average time for pings