bisect モジュールを使用したいのですが、しようとすると次のエラーが発生しますimport bisect
。
NameError: global name 'bisect_left' is not defined
そして、私が試したときのこのエラーfrom bisect import bisect_left
:
ImportError: cannot import name bisect_left
私はPythonドキュメントからこの関数を使用しようとしています:
def index(a, x):
'Locate the leftmost value exactly equal to x'
i = bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
else:
return False
私は何を間違っていますか?