python 中的set与list,tuple
2015-07-06 23:52
756 查看
__author__ = 'liunnis' #-*-coding:utf-8 -*- a=[1,2,3,4,4] print a print list(set(a)) b=[str(i) for i in a] print list(set(b)) #the result is # [1, 2, 3, 4, 4] # [1, 2, 3, 4] # ['1', '3', '2', '4'] c=[[1,2],[3,4],[5,5],[6,6],[7,8],[9,0],10,[11]] print c try: print set(c) except TypeError,e: print'Error:',e #the result is # [[1, 2], [3, 4], [5, 5], [6, 6], [7, 8], [9, 0], 10, [11]] # Error: unhashable type: 'list'
相关文章推荐
- Scrapy的安装_Python
- python 元组tuple
- 【Python 学习手册笔记】如何运行程序
- Python中的try... exception
- python2.7.7笔记if in
- 为了省钱开始学习python(1)
- python 实现冒泡算法(range函数)
- Python学习笔记
- Mac OS X在建筑Python科学计算环境
- python3.4 安装
- Python图像处理(15):SVM分类器
- [Python基础]009.os模块(1)
- Python之简单工厂模式实现
- Python - sqlalchemy Orm
- Python3.x和Python2.x的区别
- Python学习笔记_Python对象
- 如何将Mac OS X10.9下的Python2.7升级到最新的Python3.3
- python描述符
- python常用库整理
- 分享一个不错的文章