python -list

数组list

#定义一个数组
student=['jack','lisa','mark']
#打印数组
print(student)
#访问数组元素
print(student[0])
print(student[1])
print(student[-1])
#新增元素(尾部新增)
student.append("lyy")
print(student)
#新增元素(指定位置新增)
student.insert(0,'zzw')
print(student)
#删除元素(尾部删除)
student.pop()
print(student)
#删除元素(指定位置删除)
student.pop(0)
print(student)
#更改元素的值
student[0]='NO001'
print(student)

猜你喜欢

转载自www.cnblogs.com/luyinganni/p/11847352.html
今日推荐