0
作为一个蟒蛇新手,我试图编写一个脚本来记录我的互联网连接速度使用pyspeedtest,但我不明白python3脚本返回什么。我从shell运行它,它返回ping,下载和上传速度(以mbps为单位),但如果在python脚本中运行,结果是某种类型的原始数据格式。我如何将这些结果转换为标准mbps?如何从pyspeedtest结果中获取有用的数据?
import pyspeedtest
st = pyspeedtest.SpeedTest()
ping = st.ping()
download = st.download()
upload = st.upload()
print('ping: ' + str(ping))
print('download: ' + str(download))
print('upload: ' + str(upload))
如果我运行从shell(几乎同时)pyspeedtest返回
ping: 20.457208156585693
download: 79367128.02705236
upload: 8458681.882858781
我得到:
Ping: 18 ms
Download speed: 27.72 Mbps
Upload speed: 19.79 Mbps
我检查了pyspeedtest.py代码,但我还是没能弄清楚如何将python3结果转换为有用的数字。