12 列表总结

1、增:
  • append / insert
2、删:
  • remove / pop / clear / del users[2]
3、改:
  • users[3] = "新值"
4、查:
  • 索引/切片
5、列表嵌套
users = ["alex",0,True,[11,22,33,"老男孩"],[1,['alex','oldboy'],2,3]]

users[0]
users[2]
users[0][2]
users[3] # [11,22,33,"老男孩"]
users[3][-1] # "老男孩"
users[3][-1][1] # '男'
users[3] = 666

强制转换

  • list("asdfadfasfdadfasfd")

    无意义

v1 = list("asdfadfasfdadfasfd")
print(v1)
  • list( (11,22,33,44,) )
v1 = list( (11,22,33,44,) )
print(v1)
posted @ 2024-09-25 20:49  jhchena  阅读(5)  评论(0编辑  收藏  举报