我希望对'datetime‘对象的列表进行排序,并返回索引,例如排序[(2012, 6, 1, 0, 0),(2010, 1, 1, 0, 0)]并返回[2,1]。我使用了以下python代码: datetime.datetime(1985, 6, 18list indices must be integers or slices,
我尝试对int的Python列表进行排序,然后使用.pop()函数返回最高的一个。return[len(y) for y in [Ancestors(T,x) for x in OrdLeaves(T)] ].sort().pop()
在这两种情况下,.sort()都会导致列表为None (它没有.pop()函数并返回一个错误)。当我删除.sort()时,它工作得很好,但不会返回最大的int,因为列表没有排序。