B
B
Bug2019-12-06 22:44:49
Python
Bug, 2019-12-06 22:44:49

How to take values ​​from the output of the ping utility in python3?

The code:

import os
os.system('ping vk.com')

response from code:
Packet exchange with vk.com [**.***.***.**] with 32 data bytes:
Response from **.***.***.**: number of bytes=32 time=79ms TTL =50
Response from **.***.***.**: number of bytes=32 time=161ms TTL=50
Response from **.***.***.**: number of bytes=32 time= 113ms TTL=50
Response from **.***.***.**: number of bytes=32 time=130ms TTL=50
Ping statistics for **.***.***.**:
Packets: sent = 4, received = 4, lost = 0
(0% loss)
Approximate round-trip time in ms:
Minimum = 79ms, Maximum = 161ms, Average = 120ms

How do I put values ​​from the string into variables: Minimum = 79ms, Maximum = 161ms, Average = 120ms
Each value into one variable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexBoss, 2019-12-06
@thema__python3

os.popen('ping vk.com').read()
and then parsi

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question