Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 Python 新手,我正在寻找一个标准函数,它可以告诉我数组中是否存在元素。我找到了该index方法,但如果找不到该元素,它会引发异常。我只需要一些简单的函数,true如果元素在数组中或false不在数组中,它就会返回。
index
true
false
基本上相当于 PHP in_array。
in_array
>>> 1 in [0, 1, 2, 3, 4, 5] True