字符串,字典,元祖,列表
字符串:
join(拼接字符串)
val='3243fsf'.join('fsfsf')
print(val)
结果:
f3243fsfs3243fsff3243fsfs3243fsff
字典:
update(添加字典进来)
dic1={'anme':'esfsf'}
dic2={'age':20}
dic1.update(dic2)
结果:
{'anme': 'esfsf', 'age': 20}
元祖:
index(索引,查看位置)
val1=(21,33234,332,34,34).val1.index(34)
结果:
3
count(计数)
(21,33234,332,34,34).count(34)
结果:
2
例子:
dic={'23':'sefsf','43':'3443','233':'gdfgg'}
if str(43) in dic:
print('suc')
else:
print('fail')
结果:
suc
for i in dic:
print(i)
结果:
23
43
233
for k,v in dic.items():
print(k,v)
结果:
23 sefsf
43 3443
233 gdfgg
列表
extend(扩展)
val=[21,32,34]
val.extend([32,43,45,54])
结果:
[21, 32, 34, 32, 43, 45, 54]