重新定义了顺序查找的类,一直报错。请老师帮忙指点,感谢。class SC: def linear_search(self,data_set,value): for i in range(len(data_set)): if data_set == value: return i returnli=[6,34,2,0,5,475]c=SC()result=SC.linear_search(li,6)print(result) 运行结果: Traceback (most recent call last):
File "D:/Users/Administrator.3010-PC/PycharmProjects/spider/spider/kuozhan.py", line 37, in <module>
result=SC.linear_search(li,6)
TypeError: linear_search() missing 1 required positional argument: 'value' Process finished with exit code 1
在学课程 Python测试开发全栈核心课程 互联网测试工程师必修课
|