TypeError之: unsupported operand type(s) for +: 'dict_values' and 'dict_values
特此记录,翻译来看就是:dict_value类型不能用于 + 操作。
很明显是我们的用法错了,查阅了一些资料后,发现,这种用法在python2系列的代码中是允许的,然而随着python升级,这种做法就不允许了。就好像print 函数要加括号一样 ->_->
好了,解决办法如下:
例如:我们的字典为 dict_data = {‘a’:12,‘b’:23},想必大家是直接这样用了,将dict.values()直接用于相加了,其实在python3.5中不允许这样用,直接将我们的dict_data.values()(类型为dict_values())强制转换为list类型即可,即 list(dict_data.values())
TypeError之: unsupported operand type(s) for +: 'dict_values' and 'dict_values相关推荐
- 解决报错TypeError:unsupported operand type(s) for +: ‘NoneType‘ and ‘str‘
文章目录 一.问题描述 二.解决方案 Reference 一.问题描述 from pyspark.sql.types import StringType@udf(returnType = String ...
- 解决pip安装时出现报错TypeError: unsupported operand type(s) for -=: ‘Retry‘ and ‘int‘
我在Linux下使用pip安装时出现报错: Exception: Traceback (most recent call last):File "/usr/lib/python2.7/dis ...
- Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
- 成功解决TypeError: unsupported operand type(s) for +: 'dict_items' and 'list'
成功解决TypeError: unsupported operand type(s) for +: 'dict_items' and 'list' 目录 解决问题 解决思路 解决方法 解决问题 Typ ...
- 成功解决TypeError: unsupported operand type(s) for %: 'NoneType' and 'dict'
成功解决TypeError: unsupported operand type(s) for %: 'NoneType' and 'dict' 目录 解决问题 解决思路 解决方法 解决问题 TypeE ...
- 解决Python中sum函数出现的TypeError: unsupported operand type(s) for +: 'int' and 'list'错误问题
当在Python中运行sum函数时,会出现"TypeError: unsupported operand type(s) for +: 'int' and 'list'"这样的问题 ...
- tensorflow编码错误:TypeError: unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘
tensorflow 编码出现错误:TypeError: unsupported operand type(s) for *: 'float' and 'NoneType' 原码如下: import ...
- 踩坑中:TypeError: unsupported operand type(s) for /: 'str' and 'int'
在网上查看了很多博客,首先从报错提示来讲TypeError: unsupported operand type(s) for /: 'str' and 'int',明确了是类型错误:不支持操作类型为整 ...
- Django问题:TypeError: unsupported operand type(s) for -: ‘str‘ and ‘float‘
Django问题:TypeError: unsupported operand type(s) for -: 'str' and 'float Traceback (most recent call ...
最新文章
- Maven最全笔记,99%的人都收藏了!
- VS如何将核心函数封装成dll、lib,并供给第三方调用?
- linux 脚本设置时间戳,修改linux系统时间的方法(date命令)
- 第三章 Git使用入门 心得笔记
- python3+django写的个人笔记博客
- Java实现二叉树的创建、递归/非递归遍历
- Shell循环与结构化命令
- CentOS安装etcd和flannel实现Docker跨物理机通信
- windows 32位系统中进程最大可用内存空间为3GB (转)
- webpack4.x实战六,处理图片
- Unity插件——Odin 学习笔记(二)
- 什么是元数据(Metadata)?
- python 对中文文件求交集、并集、差集
- 一款免安装、多平台兼容的 拾色器(Color Picker)
- 数论-FTT 和 NTT
- 硬件设计——上拉电阻与下拉电阻
- java.applet.Applet类
- 力技艺法道,工匠师圣仙
- MATLAB实现串口通讯的详细步骤
- sqlchemy 普通索引和唯一索引
热门文章
- 工厂模式——JavaScript
- 一种监控全部账户登陆及操作命令的方法
- Cracking The Coding Interview 9.1
- [转]UTF-8 GBK UTF8 GB2312 之间的区别和关系
- PHP+JavaScript+HTML实现注册界面表单及日历控件
- Git之深入解析如何运行自己的Git仓库托管服务器
- 20万人仍然每天活跃在“死”掉的ofo APP上:这已变成一个返利应用
- 2016年第七届蓝桥杯C/C++ A组国赛 —— 第三题:打靶
- 《信息学奥赛一本通》 高精度乘法。输入两个正整数,求它们的积。
- Makefile速成