使用 Python 列表时,可以使用负索引来进行切片。a = [1,2,3,4,5,6,7,8,9] print(a[-1]) 将会输出9,如预期所示。然而,a = pd.Series([1,2,3,4,5,6,7,8,9]) print(a[-1]) 出现了KeyError: -1L 的错误。