看板 Python 關於我們 聯絡資訊
想請問板上各位先進 有辦法藉由python取得延遲時間如下紅字部分 目前只會做到ping host取得狀態 import os hostname = "google.com" #example response = os.system("ping -c 1 " + hostname) if response == 0: print(hostname, 'is up!') else: print(hostname, 'is down!') 想要把延遲時間紀錄於純文字中 謝謝了 Ping 8.8.8.8 (使用 32 位元組的資料): 回覆自 8.8.8.8: 位元組=32 時間=12ms TTL=52 回覆自 8.8.8.8: 位元組=32 時間=3ms TTL=52 回覆自 8.8.8.8: 位元組=32 時間=2ms TTL=52 回覆自 8.8.8.8: 位元組=32 時間=2ms TTL=52 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.242.44.65 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1574644908.A.42F.html
dododavid006: 你可以用 subprocess 去取得輸出 之後再用 re 取得 11/25 11:16
dododavid006: 要的部份 11/25 11:16