相关疑难解决方法(0)

检查Cython中的数组中是否存在值

我想知道如何检查数组中是否存在值或对象,例如在python中:

a = [1,2,3,4,5]
b = 4
if b in a:
    print("True!")
else:
    print("False")
Run Code Online (Sandbox Code Playgroud)

我想知道cython中是否存在类似的东西.我有一个struct对象数组指针; 我想知道该数组中是否存在该对象.

喜欢

cdef Node *array

array = <Node *>malloc( 5 * cython.sizeof(Node))

for i in range(5):
     array[i].index = i

cdef Node test = array[3]

if test in array:
    print("True!")

cdef struct Node:
    int index
Run Code Online (Sandbox Code Playgroud)

上面的代码不正确,但它说明了我的意思.

c arrays cython

25
推荐指数
1
解决办法
10万
查看次数

标签 统计

arrays ×1

c ×1

cython ×1