1.insert

A = ['1','2','3','4','5','6']
A.insert(0,0)
print A

2.append

A = ['1','2','3','4','5','6']
A.append(7)
print A

3.extend

A = ['1','2','3','4','5','6']
B = ['a','b','c']
A.extend(B)
print  A

 1.pop

A = ['1','2','3','4','5','6']
A.pop()
print A

2.remove

A = ['1','2','3','4','5','6']
A.remove('1')
print A

3.del

A = ['1','2','3','4','5','6']
del A[0]
print  A

A = ['1','2','3','4','5','6']
A[0]=0
print A

in

A = ['1','2','3','4','5','6']
for temp in A:
    print temp
A = ['1','2','3','4','5','6']
if '5'  in A:
    print '确实在'

not in 

A = ['1','2','3','4','5','6']
if '7' not in A:
    print '确实不在'

index:返回查找元素的下标

A = ['1','2','3','4','5','6']
print A.index('1')

count:返回查找元素的个数

A = ['1','2','3','4','5','6']
print A.count('1')

 列表嵌套

A = ['1','2','3','4','5','6',['1','2','3'],['4','5','6']]
for item in A:
    print  item

 元组

A = ('1','2','3','4','5','6')

元组不能修改

相关文章:

  • 2021-09-21
  • 2021-06-16
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
猜你喜欢
  • 2021-11-05
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-07-24
  • 2021-09-06
相关资源
相似解决方案