gpt4 book ai didi

python - 我如何在 python 脚本而不是命令行中使用 speedtest-cli 或任何替代方法?

转载 作者:可可西里 更新时间:2023-11-01 09:43:01 28 4
gpt4 key购买 nike

我想在我的 python 程序中使用 speedtest-cli 或任何替代方法来了解我的互联网下载和上传速度。

我为此使用 Windows,speedtest-cli 似乎在命令行中运行良好,但不知道如何在我的 python 脚本中使用它。

最佳答案

您可以使用 speedtest-cli直接安装模块,只要将其安装到当前目录即可:

curl -O https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py

现在在您的其他文件中,您可以像使用任何其他模块一样使用它:

import speedtest

speedtester = speedtest.Speedtest()
speedtester.get_best_server()

print(speedtester.download())

您也可以将其用作单线:

curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py \
| python

关于python - 我如何在 python 脚本而不是命令行中使用 speedtest-cli 或任何替代方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41716064/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com