python

python 删除redis key

2019-05-29  本文已影响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))
上一篇 下一篇

猜你喜欢

热点阅读