您的位置:首页 > 编程语言 > Python开发

python类型

2015-07-27 22:02 856 查看
本文主要总结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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: