Apr-04-2021, 08:22 PM
Apr-04-2021, 08:47 PM
You could be more specific about file types and task it should to do.
If it's a
subprocess is way for Python to run other files.
So example this will on Windows run
If it's a
.py
then module or packages is used for that trough import
.subprocess is way for Python to run other files.
So example this will on Windows run
ping.exe
and we capture output it gives.import subprocess out = subprocess.run(['ping', 'google.com'], capture_output=True, encoding='utf-8') print(out.stdout)
Output:Pinging google.com [172.217.20.46] with 32 bytes of data:
Reply from 172.217.20.46: bytes=32 time=39ms TTL=119
Reply from 172.217.20.46: bytes=32 time=39ms TTL=119
Reply from 172.217.20.46: bytes=32 time=46ms TTL=119
Reply from 172.217.20.46: bytes=32 time=53ms TTL=119
Ping statistics for 172.217.20.46:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 39ms, Maximum = 53ms, Average = 44ms
Apr-05-2021, 09:17 PM
I am wanting to run another
.py
Apr-05-2021, 09:18 PM
And I use OSX.
Apr-06-2021, 06:39 PM
If you have code in another Python module or package, then as above, import the functions, classes, etc. and use them.
Also show a code sample if you're still confused.
Also show a code sample if you're still confused.