python中使用ZADD方法报错AttributeError: 'int' object has no attribute 'items'
redis的版本关系
正确的完整实例如下:
import pymongo
import redis# 代码作用是mongodb的数据传送到redis中去
handler = pymongo.MongoClient('mongodb://adminUser:adminPass@127.0.0.1:27017').chapter_9.rank_data
client = redis.StrictRedis(password='appleyuchi',host='localhost', port=6379, db=0)
rows = handler.find({}, {'_id': 0})
redis_key="rank"for row in rows:mapping={str(row['user_id']):row['score']}client.zadd(redis_key,mapping)
注意:
这里{str(row['user_id']):row['score']}不要写成
{str(row['user_id']),row['score']},这会导致新的错误:
AttributeError: 'set' object has no attribute 'items'
python中使用ZADD方法报错AttributeError: 'int' object has no attribute 'items'相关推荐
- execjs 模块 call() 方法报错 AttributeError: ‘NoneType‘ object has no attribute ‘replace‘
使用 execjs 模块的 call() 方法时报两处错误 data = execjs.compile(open('15_exercise.js', 'r', encoding='utf-8').re ...
- 关于在《python编程从入门到实践》书中练习“外星人大战”报错“AttributeError: ‘AlienInvasion‘ object has no attribute ‘blit‘”
关于在<python编程从入门到实践>书中练习"外星人大战"报错"AttributeError: 'AlienInvasion' object has no ...
- 爬虫的自创建请求对象:报错AttributeError: 'str' object has no attribute 'items'
在使用爬虫库创建自定义请求对象时 将值传入headers agent = random.choice(userAgent) REQ = request.Request(url,headers=agen ...
- python使用redis zadd方法报错(error) ERR value is not a valid float
代码本来是跑通的,但是因需求调整,项目需要支持redis集群模式,故对Python的redis包进行调整,调整后的版本号为: redis 2.10.6 redis-py-clus ...
- python 交互redis 的ZADD方法异常: AttributeError: ‘int‘ object has no attribute ‘items‘
2019.8.15更新 代理池异常的原因,是因为在db.py中zadd方法没有修改完全. def max(self, proxy):"""将代理设置为MAX_SCORE: ...
- python2 中使用pip2 install package_name的时候报错:AttributeError: ‘int‘ object has no attribute ‘endswith‘
1 错误说明 1.在python2的环境下使用pip2 install安装库包的时候报错:AttributeError: 'int' object has no attribute 'endswith ...
- python使用Axes3D画三维图加入legend图例时报错AttributeError: ‘Poly3DCollection‘ object has no attribute ‘_edgecolo
Q:python使用Axes3D画三维图加入legend图例时报错AttributeError: 'Poly3DCollection' object has no attribute '_edgeco ...
- Scrapy爬虫报错AttributeError: ‘NoneType‘ object has no attribute ‘write‘
前言 一.报错 AttributeError: 'NoneType' object has no attribute 'write' 二.报错原因 1.piplines文件中的方法不能自定义的呢 开始 ...
- 运行项目时flask_sqlalchemy报错AttributeError: ‘LocalStack‘ object has no attribute ‘__ident_func__‘
运行项目时flask_sqlalchemy报错AttributeError: 'LocalStack' object has no attribute '__ident_func__' 1.原因 2. ...
最新文章
- 《VMware Virtual SAN权威指南(原书第2版)》一1.5 什么是Virtual SAN
- android快捷开发之Retrofit网络加载框架的简单使用
- neo4j python 算法_图论与图学习(二):图算法
- 如何获取STM32 MCU的唯一ID
- prev php,PHP prev() 函数 ——jQuery中文网
- 机器学习与计算机视觉(FPGA的图像处理方法)
- NET框架下使用双缓冲技术绘图
- 10g CRS Clustware Installation安装图
- 全国dns服务器地址
- 在鼠标点击的位置 ,添加一个div ,类似手表右键菜单
- Java添加水印文字
- 无人驾驶 ai算法_AI机器学习具有碳足迹,因此无人驾驶汽车也是如此
- python辗转相除法求最大公约数_vb编程实现用辗转相除法求两个数a和b的最大公约数...
- 自动控制理论(9)——奈奎斯特稳定判据
- js判断数组key是否存在
- STM32通过IIC驱动MLX90614红外温度传感器
- 某Xavier载板硬件方案
- 【必读推荐】程序员的职业素养
- 【转】ubuntu下为APT设置代理
- 半阳不阳后的一些总结
热门文章
- MIFARE系列5《存储结构》
- 利用Quartz2D-contex绘制三角形
- 哪种代理适合用于Web数据采集
- iis负载均衡与文件同步[网摘]
- JS报错:Uncaught RangeError: Maximum call stack size exceeded
- vue install 报错 This is a problem related to network connectivity.
- 山东大学计算机系统原理,山东大学计算机组成原理三套题汇总
- 简单实现实时输入网页,参考vue底层实现
- [Vue源码分析] Virtual DOM
- scala 主构造函数_在Scala中,如何在类的主构造函数中定义局部参数?