马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
>>> rhyme = [1, 2, 3, 4, 5, "上山打老虎"]
>>> print(rhyme)
[1, 2, 3, 4, 5, '上山打老虎']
>>> for each in rhyme:
... print(each)
...
1
2
3
4
5
上山打老虎
>>> rhyme[0]
1
>>> rhyme[5]
'上山打老虎'
>>> rhyme[-1]
'上山打老虎'
>>> rhyme[0:3]
[1, 2, 3]
>>> rhyme[3:6]
[4, 5, '上山打老虎']
>>> rhyme[:3]
[1, 2, 3]
>>> rhyme[3:]
[4, 5, '上山打老虎']
>>> rhyme[:]
[1, 2, 3, 4, 5, '上山打老虎']
>>> rhyme[0:6:2]
[1, 3, 5]
>>> rhyme[::2]
[1, 3, 5]
>>> rhyme[::-2]
['上山打老虎', 4, 2]
>>> rhyme[::-1]
['上山打老虎', 5, 4, 3, 2, 1] |