slice:
member[1:3]
课后作业:
0. 2,9,7
1. list1[0]= 1
list1[0:1] = list1[1]
2.
方法一:
>>> member
[‘信服‘, ‘科技‘, ‘知识‘, ‘到款‘, ‘好吧‘]
>>> name = member.pop()
>>> name
‘好吧‘
>>> member.insert(0,name)
>>> member
[‘好吧‘, ‘信服‘, ‘科技‘, ‘知识‘, ‘到款‘]
方法二:
>>>list1.insert(0, list1.pop())
3.
list1=[1,3,2,9,7,8]
list1[-3:-1]
result: [9,7]
从后往前数0,-1,-2,-3
4.
list1=[1,3,2,9,7,8]
list1[0:6:2] 相当于 list1[0],list1[2],list1[4]
1,2,7
5.
不可以
原文地址:https://www.cnblogs.com/jiangkeji/p/9030615.html
时间: 2024-10-09 13:50:19