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'相关推荐

  1. execjs 模块 call() 方法报错 AttributeError: ‘NoneType‘ object has no attribute ‘replace‘

    使用 execjs 模块的 call() 方法时报两处错误 data = execjs.compile(open('15_exercise.js', 'r', encoding='utf-8').re ...

  2. 关于在《python编程从入门到实践》书中练习“外星人大战”报错“AttributeError: ‘AlienInvasion‘ object has no attribute ‘blit‘”

    关于在<python编程从入门到实践>书中练习"外星人大战"报错"AttributeError: 'AlienInvasion' object has no ...

  3. 爬虫的自创建请求对象:报错AttributeError: 'str' object has no attribute 'items'

    在使用爬虫库创建自定义请求对象时 将值传入headers agent = random.choice(userAgent) REQ = request.Request(url,headers=agen ...

  4. python使用redis zadd方法报错(error) ERR value is not a valid float

    代码本来是跑通的,但是因需求调整,项目需要支持redis集群模式,故对Python的redis包进行调整,调整后的版本号为: redis            2.10.6 redis-py-clus ...

  5. python 交互redis 的ZADD方法异常: AttributeError: ‘int‘ object has no attribute ‘items‘

    2019.8.15更新 代理池异常的原因,是因为在db.py中zadd方法没有修改完全. def max(self, proxy):"""将代理设置为MAX_SCORE: ...

  6. python2 中使用pip2 install package_name的时候报错:AttributeError: ‘int‘ object has no attribute ‘endswith‘

    1 错误说明 1.在python2的环境下使用pip2 install安装库包的时候报错:AttributeError: 'int' object has no attribute 'endswith ...

  7. python使用Axes3D画三维图加入legend图例时报错AttributeError: ‘Poly3DCollection‘ object has no attribute ‘_edgecolo

    Q:python使用Axes3D画三维图加入legend图例时报错AttributeError: 'Poly3DCollection' object has no attribute '_edgeco ...

  8. Scrapy爬虫报错AttributeError: ‘NoneType‘ object has no attribute ‘write‘

    前言 一.报错 AttributeError: 'NoneType' object has no attribute 'write' 二.报错原因 1.piplines文件中的方法不能自定义的呢 开始 ...

  9. 运行项目时flask_sqlalchemy报错AttributeError: ‘LocalStack‘ object has no attribute ‘__ident_func__‘

    运行项目时flask_sqlalchemy报错AttributeError: 'LocalStack' object has no attribute '__ident_func__' 1.原因 2. ...

最新文章

  1. 《VMware Virtual SAN权威指南(原书第2版)》一1.5 什么是Virtual SAN
  2. android快捷开发之Retrofit网络加载框架的简单使用
  3. neo4j python 算法_图论与图学习(二):图算法
  4. 如何获取STM32 MCU的唯一ID
  5. prev php,PHP prev() 函数 ——jQuery中文网
  6. 机器学习与计算机视觉(FPGA的图像处理方法)
  7. NET框架下使用双缓冲技术绘图
  8. 10g CRS Clustware Installation安装图
  9. 全国dns服务器地址
  10. 在鼠标点击的位置 ,添加一个div ,类似手表右键菜单
  11. Java添加水印文字
  12. 无人驾驶 ai算法_AI机器学习具有碳足迹,因此无人驾驶汽车也是如此
  13. python辗转相除法求最大公约数_vb编程实现用辗转相除法求两个数a和b的最大公约数...
  14. 自动控制理论(9)——奈奎斯特稳定判据
  15. js判断数组key是否存在
  16. STM32通过IIC驱动MLX90614红外温度传感器
  17. 某Xavier载板硬件方案
  18. 【必读推荐】程序员的职业素养
  19. 【转】ubuntu下为APT设置代理
  20. 半阳不阳后的一些总结

热门文章

  1. MIFARE系列5《存储结构》
  2. 利用Quartz2D-contex绘制三角形
  3. 哪种代理适合用于Web数据采集
  4. iis负载均衡与文件同步[网摘]
  5. JS报错:Uncaught RangeError: Maximum call stack size exceeded
  6. vue install 报错 This is a problem related to network connectivity.
  7. 山东大学计算机系统原理,山东大学计算机组成原理三套题汇总
  8. 简单实现实时输入网页,参考vue底层实现
  9. [Vue源码分析] Virtual DOM
  10. scala 主构造函数_在Scala中,如何在类的主构造函数中定义局部参数?