美文网首页python
python 删除redis key

python 删除redis key

作者: 迷糊银儿 | 来源:发表于2019-05-29 21:35 被阅读0次

一、为Python安装Redis库

  1. https://github.com/andymccurdy/redis-py 后点击Download ZIP下载安装包
  2. 解压安装包redis-py-master.zip
  3. 安装
cd redis-py-master
python setup.py install

二、python 文件

假设redis的key值为 h1,h2,,,,一直到h63

import redis
pool = redis.ConnectionPool(host='10.102.36.12', port=8567, decode_responses=True)
conn = redis.Redis(connection_pool=pool)
for i in range (1,64):
        key="h"+str(i)
        #print(conn.get(key))
        conn.delete(key)
        print(conn.get(key))

相关文章

网友评论

    本文标题:python 删除redis key

    本文链接:https://www.haomeiwen.com/subject/djwutctx.html