简体   繁体   English

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

[英]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.

相关问题 speedtest-cli 在控制台中工作,但不能作为脚本使用 - speedtest-cli works in console, but not as script 在 Python3 脚本中使用 speedtest-cli 来测量互联网速度 - 收到错误消息“No module named speedtest” - Using speedtest-cli within a Python3 script to measure internet speed - getting error message 'No module named speedtest' 不同界面上的 Speedtest-cli - Speedtest-cli on a different interface 创建一个python函数以在终端中运行speedtest-cli / ping并将结果输出到日志文件 - Create a python function to run speedtest-cli/ping in terminal and output result to a log file 有没有办法在速度测试期间使用 Python 的 speedtest-cli 库实时绘制实时下载/上传速度? - Is there a way to graph the real-time download/upload speed real time during a speed test using the speedtest-cli library for Python? 更改 speedtest.py 和 speedtest-cli 的 output 以将 IP 地址包含在 output.Z628Z19675FFE88FEF3F 文件中 - Changing output of speedtest.py and speedtest-cli to include IP address in output .csv file 如何在命令行上接受用户输入的python脚本而不是提示 - How do I accept user input on command line for python script instead of prompt 如何修改 python 脚本以使用外部文件作为命令行中的输入? - How do I modify a python script to use an external file as the input in the command line? 我如何使用 python 脚本中的命令行 - How can i use command line from python script 如何将 python 脚本 arguments 传递给 Azure CLI `az ml run submit-script` 命令? - How do I pass in python script arguments to Azure CLI `az ml run submit-script` command?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM