Speedtest python脚本

时间:2018-01-16 20:52:08

标签: python

你好,我是python的新手,我正在尝试使用python从(speedtest.net)获取数据进行速度测试。我一直在寻找git hub并找到了speedtest-cli。但它有很多我不需要的功能。我只想制作一个将运行3次的简单脚本。我发现了一些API,但我不知道如何将其修改为循环三次。任何帮助将不胜感激。提前致谢

import speedtest

servers = []
# If you want to test against a specific server
# servers = [1234]
x=0
for x in range(0, 2):
    s = speedtest.Speedtest()
    s.get_servers(servers)
    s.get_best_server()
    s.download()
    s.upload()
    s.results.share()
    results_dict = s.results.dict()

3 个答案:

答案 0 :(得分:4)

// Called from within render() to wrap a span around a search term embedded in the artist, album or track name
underlineSearch(displayString) {
    const searchTerm = this.props.searchTerm;
    const indexOfSearchTerm = displayString.indexOf(searchTerm);

    let node;
    if (indexOfSearchTerm === -1) {
        node = displayString;
    } else {
        node = (
          <React.Fragment>
            {displayString.substr(0, indexOfSearchTerm)}
            <span style={{color: 'green'}}>
              {displayString.substr(indexOfSearchTerm, searchTerm.length)}
            </span>
            {displayString.substr(indexOfSearchTerm + searchTerm.length)}
          </React.Fragment>
        );
    }

    return node;
}

答案 1 :(得分:1)

我们可以使用这种方式

  patient  letter    V2    V3    V4    V5 V6    V7   
  <chr>    <chr>  <int> <int> <int> <int> <chr> <chr>
1 patientc A          1     2     3     4 b     c    
2 patientc B          1     2     3     4 b     c    
3 patientd A          3     3     5     6 d     e    
4 patientd B          3     3     5     6 d     e  

答案 2 :(得分:0)

有一种方法可以更轻松地使用库Pyspeedtest

import pyspeedtest
st = pyspeedtest.SpeedTest()
st.ping()

https://pypi.org/project/pyspeedtest/