Python入门系列教程(三)列表和元组

时间:2024-04-17 21:06:54

1.insert

A = ['','','','','','']
A.insert(0,0)
print A

2.append

A = ['','','','','','']
A.append(7)
print A

3.extend

A = ['','','','','','']
B = ['a','b','c']
A.extend(B)
print A

1.pop

A = ['','','','','','']
A.pop()
print A

2.remove

A = ['','','','','','']
A.remove('')
print A

3.del

A = ['','','','','','']
del A[0]
print A

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

in

A = ['','','','','','']
for temp in A:
print temp
A = ['','','','','','']
if '' in A:
print '确实在'

not in

A = ['','','','','','']
if '' not in A:
print '确实不在'

index:返回查找元素的下标

A = ['','','','','','']
print A.index('')

count:返回查找元素的个数

A = ['','','','','','']
print A.count('')

列表嵌套

A = ['','','','','','',['','',''],['','','']]
for item in A:
print item

元组

A = ('','','','','','')

元组不能修改