在python中,有一个模块与之密切相关,就是bisect
1 import bisect 2 3 4 def func(): 5 a = [1, 5, 9] 6 bisect.insort(a, 6) 7 return a 8 9 10 if __name__ == '__main__': 11 print(func())
output:
[1, 5, 6, 9]
posted on 2022-11-21 10:03 默玖 阅读(8) 评论(0) 编辑 收藏 举报
Powered by: 博客园 Copyright © 2024 默玖 Powered by .NET 8.0 on Kubernetes