赞
踩
1.set集合
可变集合(set):可添加和删除元素,非可哈希的,不能用作字典的键,也不能做其他集合的元素
不可变集合(frozenset):与上面恰恰相反
Paste_Image.png
创建集合
>>> s = set('beginman')
>>> s
set(['a', 'b', 'e', 'g', 'i', 'm', 'n'])
>>> t = frozenset('pythonman')
>>> t
frozenset(['a', 'h', 'm', 'o', 'n', 'p', 't', 'y'])
>>> type(s),type(t)
(, )
>>>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。