(Sep-24-2023, 11:09 AM)akbarza Wrote: hi snippetTo explain the basic of this,so ping is a external program
I am not familiar with the subprocess library and your code:
response = subprocess.run(['ping', '-n' ,'4', 'python-forum.io'], capture_output=True, encoding='utf-8')how(where) can I gain more info about the above code?
ping.exe
that you have on your OS Windows .From
cmd
:C:\>ping -n 4 python-forum.io Pinging python-forum.io [172.67.168.227] with 32 bytes of data: Reply from 172.67.168.227: bytes=32 time=21ms TTL=53 Reply from 172.67.168.227: bytes=32 time=37ms TTL=53 Reply from 172.67.168.227: bytes=32 time=32ms TTL=53 Reply from 172.67.168.227: bytes=32 time=35ms TTL=53 Ping statistics for 172.67.168.227: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 21ms, Maximum = 37ms, Average = 31msSo it's a way to take a external programs into Python,and run it if program have output can also catch that.
Like this will just start FireFox from Python.
import subprocess subprocess.run(['C:/Program Files (x86)/Mozilla Firefox/firefox.exe'])Look at Doc for eg run().