“ TypeError:类型为'type'的对象没有len()“-在Python上进行线性搜索

时间:2019-09-04 12:41:16

标签: python python-3.x linear-search

我对Python还是有点陌生​​,今天我想做一个线性搜索算法,但是tx("Hello, world!", txdone_func); void tx(const char *str, osjobcb_t func) { os_radio(RADIO_RST); // Stop RX first delay(1); // Wait a bit, without this os_radio below asserts, apparently because the state hasn't changed yet LMIC.dataLen = 0; while (*str) LMIC.frame[LMIC.dataLen++] = *str++; LMIC.osjob.func = func; os_radio(RADIO_TX); Serial.println("TX"); } 遇到了问题:

tx(test, txdone_func,test_counter);

void tx(byte inc[], osjobcb_t func, int inc_size) {
    os_radio(RADIO_RST); // Stop RX first
    delay(1); // Wait a bit, without this os_radio below asserts, apparently because the state hasn't changed yet
    LMIC.dataLen = 0;
    for (int i = 0; i < inc_size; i++) {
        LMIC.frame[LMIC.dataLen++] = inc[i];
    }
    LMIC.osjob.func = func;
    os_radio(RADIO_TX);
    Serial.println("TX");
}

我希望输出什么也不会给出或len(list),因为我仍在测试 但是我一直收到此错误消息。

1 个答案:

答案 0 :(得分:0)

“列表”是数据类型的保留字。您应该避免将其用于变量。这就是为什么您会得到错误,解释认为它是数据结构中的列表。