# -*- coding: GBK -*-

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])

输出为:

['charles', 'martina', 'michael']

2、中间提取

# -*- coding: GBK -*-

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[1:4])

输出为:

['martina', 'michael', 'florence']

3、列表开头开始

# -*- coding: GBK -*-

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[:4])

输出为:

['martina', 'michael', 'florence']

4、到末尾

# -*- coding: GBK -*-

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[2:])

输出为:

['michael', 'florence', 'eli']

5、倒数

# -*- coding: GBK -*-

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[-3:])

输出为:

['michael', 'florence', 'eli']
05-21 05:02