[英]How do i use speedtest-cli or any alternative in python script instead of command line?
I would like to use speedtest-cli or any alternative in my python program to know my internet download and upload speed. 我想在我的python程序中使用speedtest-cli或任何替代方法来了解我的互联网下载和上传速度。
Am using windows for this and speedtest-cli seems to work well in the command line but don't know how to use it in my python script. 我正在使用Windows和speedtest-cli似乎在命令行中运行良好,但不知道如何在我的python脚本中使用它。
You can use the speedtest-cli module directly, as long as you install it into your current directory: 您可以直接使用speedtest-cli模块,只要将其安装到当前目录中即可:
curl -O https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
Now in your other file you can use it as you would any other module: 现在在您的其他文件中,您可以像使用任何其他模块一样使用它:
import speedtest
speedtester = speedtest.Speedtest()
speedtester.get_best_server()
print(speedtester.download())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.