import os
os.system("wget -O /dev/null http://65.0.164.107/5MB.zip 2>&1 |grep -o '[0-9.]\+ [KM]*B/s'")
Here the above sample shows the download speed of the internet and I have to assign the result of the above to a variable and perform further operations. How can I save the above os.system to a variable?
for example, The above code displays the output as
5 mb/s
I wanna assign it to a variable
import os
a = os.system("wget -O /dev/null http://65.0.164.107/5MB.zip 2>&1 |grep -o '[0-9.]\+ [KM]*B/s'")
print(a)
It should output like
5 Mb/s or 5
I need solution to assign the output of that command to some variable and use it for further operations with it. I have tried many solutions but that's not working.
I just need to assign the command value to a variabl, any method in python will be fine.