Python3基础 list dict set 均为unhashable type
- Python : 3.7.3
- OS : Ubuntu 18.04.2 LTS
- IDE : pycharm-community-2019.1.3
- Conda : 4.7.5
- typesetting : Markdown
code
coder@ubuntu:~$ source activate py37
(py37) coder@ubuntu:~$ ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: hash(list())
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-3e2eb619e4e4> in <module>
----> 1 hash(list())
TypeError: unhashable type: 'list'
In [2]: hash(dict())
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-7762fff637c6> in <module>
----> 1 hash(dict())
TypeError: unhashable type: 'dict'
In [3]: hash(set())
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-2699417ebeac> in <module>
----> 1 hash(set())
TypeError: unhashable type: 'set'
In [4]: exit
(py37) coder@ubuntu:~$ conda deactivate
coder@ubuntu:~$
source_code
def hash(*args, **kwargs): # real signature unknown
"""
Return the hash value for the given object.
Two objects that compare equal must also have the same hash value, but the
reverse is not necessarily true.
"""
pass
reference
- https://blog.csdn.net/u013939918/article/details/78032046
- https://www.jianshu.com/p/49f940b2c03e
- https://blog.csdn.net/weixin_37641832/article/details/84332763
resource
- [文档 - English] docs.python.org/3
- [文档 - 中文] docs.python.org/zh-cn/3
- [规范] www.python.org/dev/peps/pep-0008
- [规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
- [源码] www.python.org/downloads/source
- [ PEP ] www.python.org/dev/peps
- [平台] www.cnblogs.com
- [平台] gitee.com
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。
Python3基础 list dict set 均为unhashable type的更多相关文章
- python基础中遇到的问题(TypeError: unhashable type: 'list')
d20220330 #false >>> l=[{i:i+1} for i in [1,2,3]] >>> l [{1: 2}, {2: 3}, {3: 4}] & ...
- Python3基础 list(dict) 使用 * 扩充时,出现字典元素重复问题
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- python基础——使用dict和set
python基础——使用dict和set dict Python内置了字典:dict的支持,dict全称dictionary,在其它语言中也称为map(映射),使用键-值(key-value)存储,具 ...
- Python3基础之数据类型(字典)
Python3数据类型之 字典 字典是另一种可变容器模型,且可存储任意类型对象. 字典的每个键值(key=>value)对用冒号(:)分割,每个对之间用逗号(,)分割,整个字典包括在花括号({} ...
- python基础之dict、set及字符
python基础之dict.set及字符串处理 本节内容 字典介绍及内置方法 集合介绍 字符串处理 1.字典介绍及内置方法 字典是python中唯一的映射类型,采用键值对(key-value)的形式存 ...
- 第四篇:python基础之dict、set及字符
python基础之dict.set及字符 python基础之dict.set及字符串处理 本节内容 字典介绍及内置方法 集合介绍 字符串处理 1.字典介绍及内置方法 字典是python中唯一的映射 ...
- python3基础视频教程
随着目前Python行业的薪资水平越来越高,很多人想加入该行业拿高薪.有没有想通过视频教程入门的同学们?这份Python教程全集等你来学习啦! python3基础视频教程:http://pan.bai ...
- Python3基础教程2——Python的标准数据类型
2018年3月12日 这次介绍一些python里面的标准数据类型 当然还是推荐一个比较系统的教程 http://www.runoob.com/python3/python3-tutorial.html ...
- Python3基础-特别函数(map filter partial reduces sorted)实例学习
1. 装饰器 关于Python装饰器的讲解,网上一搜有很多资料,有些资料讲的很详细.因此,我不再详述,我会给出一些连接,帮助理解. 探究functools模块wraps装饰器的用途 案例1 impor ...
随机推荐
- Linux 里的 2>&1 究竟是什么
原文 我们在Linux下经常会碰到nohup command>/dev/null 2>&1 &这样形式的命令.首先我们把这条命令大概分解下: 首先就是一个nohup:表示当 ...
- Cloudera Certified Associate Administrator案例之Troubleshoot篇
Cloudera Certified Associate Administrator案例之Troubleshoot篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.调整日志的进 ...
- 虚拟机网络设置(NAT模式)
虚拟机网络设置(NAT模式) linux 1. 设置虚拟机网络 1.1. NAT子网设置 1.2. 网卡配置文件设置 1.3. 重启网络服务 1.4. 配置端口转发 2. 配置网络共享 预期想要搭建本 ...
- centos 7 修改密码
linux管理员忘记root密码,需要进行找回操作. 注意事项:本文基于centos7环境进行操作,由于centos的版本是有差异的,继续之前请确定好版本. 操作步骤 一.重启系统,在开机过程中,快速 ...
- Python语言程序设计(3)--字符串类型及操作--time库进度条
1.字符串类型的表示: 三引号可做注释,注释其实也是字符串 2.字符串的操作符 3.字符串处理函数 输出:
- HBase应用
太多column family的影响 每个 MemoryStore分配到的内存较少,进而导致过多的合并,影响性能 几个column family比较合适呢 推荐是:1-3个 划分column fa ...
- GITHUB手册
GitHub 指南 原文地址:GitHub官网指南 示例项目:Hello World 十分钟轻松教学 在学习计算机语言编程的过程中创建Hello World 项目是一个历史悠久的传统.当你接触一门新事 ...
- 多项式的各类计算(多项式的逆/开根/对数/exp/带余除法/多点求值)
预备知识:FFT/NTT 多项式的逆 给定一个多项式 F(x)F(x)F(x),请求出一个多项式 G(x)G(x)G(x),满足 F(x)∗G(x)≡1(mod xn)F(x)*G(x) \equiv ...
- LeetCode 708. Insert into a Cyclic Sorted List
原题链接在这里:https://leetcode.com/problems/insert-into-a-cyclic-sorted-list/ 题目: Given a node from a cycl ...
- LeetCode 439. Ternary Expression Parser
原题链接在这里:https://leetcode.com/problems/ternary-expression-parser/description/ 题目: Given a string repr ...