是否有一个很好的简短方法来判断python列表(或numpy数组)是否包含带有交替符号的数字?换一种说法:
is_alternating_signs([1, -1, 1, -1, 1]) == True is_alternating_signs([-1, 1, -1, 1, -1]) == True is_alternating_signs([1, -1, 1, -1, -1]) == False
python numpy
numpy ×1
python ×1