class sorted_list(object): def __init__(self,elements): self.elements=sorted(elements) def __iter__(self): self.position=-1 return self def __next__(self): if self.position == len(self.elements)-1: raise StopIteration self.position+=1 return self.elements[self.position] namelist=['a','d','c'] sorted_namelist=sorted_list(namelist)#提示这一行 超过最大迭代深度限制for name in sorted_namelist: print(name)
犯罪嫌疑人X
相关分类