本文主要总结python的集中数据类型。
1)字符创(string)
str = 'l love China'
print str
2))列表(list)
list = ['abc',12,'12']
list.append()
list.remove()
2)元组(tuple)可以认为是只读的list,不可修改。
tup = ('abc',12,'12')
print tup[0]
3)字典(dictionary)。列表是有序的对象集合,字典是无序的对象集合。字典中的元素通过键来取值,而列表的元素是通过偏移来取值的。
dict = {'123':35,11:'sp'}
dict['123']
del dict[]
del dict
dict.clear()
4)集合(set )。集合可以有list初始化。
a = set([])
a.add(123)
a.remove()