import pandas as pd temp = pd.Series([1,2,3,4,5]) loc用法: temp.loc[0:3] 0 1 1 2 2 3 3 4 # 输出索引为0-3的值(基于索引) temp.loc[-1] 报错 iloc用法: temp.iloc[0:3] 0 1 1 2 2 3 #输出前三个值(基于位置) temp.iloc[-1] 5