__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'

python 中的set与list,tuple的更多相关文章

  1. Python中内置数据类型list,tuple,dict,set的区别和用法

    Python中内置数据类型list,tuple,dict,set的区别和用法 Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个内置数据类型功不可没,他们即是list, ...

  2. Python中的数据结构 --- 元组(tuple)、字典(tuple)

       元组(tuple)本身是不可变数据类型,没有增删改查:元组内可以存储任意数据类型一.元组的创建 例:t = (1,2.3,'star',[1,2,3])      ## 元组里面包含可变类型,故 ...

  3. python中的list()函数和tuple()函数

    tuple函数:将一个序列作为参数,并把它转化为元组,如果参数是元组,将会原样返回: >>> tuple([1,2,3]) (1, 2, 3) >>> tuple( ...

  4. Python中几种数据类型list, tuple,dict,set的使用演示

    还是直接上代码,看着代码运行,看函数介绍 # coding=utf-8 # 1 list-列表 的用法 students = [1,2,3] a = 5 classmates = [students* ...

  5. python中元组tuple

    python中列表(list)和元组(tuple)有很多相似的地方,它们都是容器,由一系列的对象构成,都可以包含任意类型的元素,甚至是一个序列.   list和tuple的不同首先体现在写法上: li ...

  6. 详解Python中内置的NotImplemented类型的用法

    它是什么? ? 1 2 >>> type(NotImplemented) <type 'NotImplementedType'> NotImplemented 是Pyth ...

  7. Python中list,tuple,dict,set的区别和用法

    Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个内置数据类型功不可没,他们即是list, tuple, dict, set.这里对他们进行一个简明的总结. List ...

  8. Python中的List,Tuple,Dic,Set

    Python中的List,Tuple,Dic,Set List定义 序列是Python中最基本的数据结构.序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推 ...

  9. python中的字典(dict),列表(list),元组(tuple)

    一,List:列表 python内置的一种数据类型是列表:list.list是一种有序的数据集合,可以随意的添加和删除其中的数据.比如列出班里所有的同学的名字,列出所有工厂员工的工号等都是可以用到列表 ...

随机推荐

  1. iOS开源项目周报0316

    由OpenDigg 出品的iOS开源项目周报第十二期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等.GodEye  ...

  2. protobuf简单测试应用

    protobuf是google推出的一种数据交换协议,比较适合应用于底层服务交互,nodejs提供protobufjs包的实现,下面是一个简单的测试demo: 首先是.proto文件: package ...

  3. apache 优化配置详解

    ###=========httpd.conf begin===================##Apache主配置文件##设置服务器的基础目录,默认为Apache安装目录ServerRoot &qu ...

  4. [LeetCode]Longest Substring Without Repeating Characters题解

    Longest Substring Without Repeating Characters: Given a string, find the length of the longest subst ...

  5. spss C# 二次开发 学习笔记(五)——Spss系统集成模式

    Spss官方不支持Server2008R2等Server系列,但做Spss的二次开发,调用Spss的Web系统,一般部署在Server系列上,例如Server2008R2. 起初,在Server上安装 ...

  6. JDBC入门(5)--- 时间类型、大数据

    一.时间类型 数据库类型与Java中类型的对应关系: DATE->java.sql.Date:表示日期,只有年月日,没有时分秒,会丢失时间. TIME->java.sql.Time:表示时 ...

  7. Excel Metadata

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  8. PoPo数据可视化周刊第一期

    PoPo数据可视化 聚焦于Web数据可视化领域, 发现前端可视化领域有意思的内容. 涵盖前端可视化领域最新资讯, 开源可视化库的发布更新消息, 可视化案例分析与讲解, 可视化技术文章, 可视化大神的日 ...

  9. Uncaught TypeError: _react2.default.createContext is not a function

    question is caused by react version, update your react version, it will be ok. use "npm update ...

  10. drupal7区块内容对象

    区块内容对象