Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在排序列表或给定数据中搜索特定数据?_Python_Sortedlist - Fatal编程技术网

Python 如何在排序列表或给定数据中搜索特定数据?

Python 如何在排序列表或给定数据中搜索特定数据?,python,sortedlist,Python,Sortedlist,如果您看到它没有显示列表中的35个位置 它没有打印值,因为您告诉它只打印标题文本,而不是值 Enter the required key: 35 Your search key is at position: 解决了这个问题: if found: print("Your search key is at position: ", mid_indx) 如果在_xyz的数据_中搜索_键,则查找=数据_的_xyz.索引(搜索_键)不容易,否则无?或者您只是想知道搜索函数的实现是否正确?变

如果您看到它没有显示列表中的35个位置

它没有打印值,因为您告诉它只打印标题文本,而不是值

Enter the required key: 35
Your search key is at position: 
解决了这个问题:

if found:
    print("Your search key is at position: ", mid_indx)

如果在_xyz的数据_中搜索_键,则查找=数据_的_xyz.索引(搜索_键)不容易,否则无?或者您只是想知道搜索函数的实现是否正确?变量和函数名称应遵循带有下划线的
小写形式。你认为
如果找到==True:
如何工作?是的!你说得对,它确实像你提到的那样工作了,谢谢你!
if found:
    print("Your search key is at position: ", mid_indx)
[13, 24, 32, 35, 78]
Enter the required key: 35
Your search key is at position:  3