a = ['liu', 'yuan', 'is', 'a', 'chinese']
bisect_left(a, 'is')
此模块可以查找已知的element在序列中的index(从左向右找出第一个)
Python Doc
http://docs.python.org/release/2.5/lib/module-bisect.html
| <nobr><strong><tt id="l2h-746" class="function" style="font-family:'lucida typewriter',lucidatypewriter,monospace">bisect_left</tt></strong>(</nobr> | list, item[, lo[, hi]]) |
list.insert(). This assumes that
listis already sorted.
New in version 2.1.
本文介绍了Python标准库中bisect模块的bisect_left函数。该函数用于在一个已排序的序列中找到指定元素的插入位置,确保序列仍保持有序状态。同时,如果元素已经存在于序列中,函数将返回在现有条目左侧的位置。
2170

被折叠的 条评论
为什么被折叠?



