当然我们在开始测网速之前需要提前下载好依赖的模块
pip install speedtest-cli
然后我们开始尝试测试一下网速:
from speedtest import Speedtest
def Testing_Speed(net):
download = net.download()
upload = net.upload()
print(f'下载速度: {download/(1024*1024)} Mbps')
print(f'上传速度: {upload/(1024*1024)} Mbps')
print("开始网速的测试 ...")
net = Speedtest()
Testing_Speed(net)