testList = ['nice', 'to', 'meet', 'you'] for i, x in enumerate(testList): print(i, x) #enumerate利用枚举函数输出索引和值