首页 > 数据库 >python简单操作redis

python简单操作redis

时间:2022-08-22 08:00:21浏览次数:56  
标签:test1 indexKey python redis indexValue1 keys 简单 print

redis操作

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r.set('test1', 'test1')


value1 = r.get('car')
print(value1)

all_keys = r.keys()
print(all_keys)

for indexKey in all_keys:
    indexValue1 = r.get(indexKey)
    print(indexValue1)


if r.exists("test1"):
    r.delete("test1")


all_keys = r.keys()
print(all_keys)

for indexKey in all_keys:
    indexValue1 = r.get(indexKey)
    print(indexValue1)

 

 

 

#################

标签:test1,indexKey,python,redis,indexValue1,keys,简单,print
From: https://www.cnblogs.com/herd/p/16611632.html

相关文章

  • 8/21 python基础学习4
    第九章类类的创建:classDog:def__init__(self,name,age):#初始化函数self.name=nameself.age=agedefsit(self):pri......
  • Python数据库编程
    1.操作SQLite3数据库  Python3.x版本开始,在标准库中已经内置了SQLlite3模块,它可以支持SQLite3数据库的访问和相关的数据库操作。在需要操作SQLite3数据库数据时,只须在......
  • 【Redis】模糊查询
    Redis模糊查询1、支持的通配符*、?、[]2、通配符*a、单个*模式#查询所有的keykeys*b、双*模式,匹配任意多个字符#key中含有rich的keykeys*rich*3、通配符......
  • python: 绘制数学函数
    1importmatplotlib.pyplotasplt2importnumpyasnp34#100linearlyspacednumbers5x=np.linspace(-5,5,100)67#thefunction,whichisy=......
  • golang 查询 ES 最简单的 demo
    分页多条件查询ESfuncTestESQueryDemo(){//ESSDK教程:https://www.yisu.com/zixun/694102.html query:=elastic.NewBoolQuery().Must......
  • redis安装脚本
    #!/bin/bash#-*-codeing=utf-8-*-#@Time:2021/11/722:11#@Author:xiaoguaishou#@File:redis_install.sh#@Software:PyCharm#1.设置redis安装目录......
  • 系统学Python(四)字符串
    今天我们来学习字符串。python中的字符串字面量由单引号或双引号括起。str1='hello'str2="hello"#两种写法效果一样print(str1)print(str2)print(type(str1),t......
  • Python_08While循环
    while循环Python提供了While和for循环,(在Python中没有do..while循环)如果使用 while 循环,给定的判断条件为true时执循环体,否则退出循环体。1#在Python中没有do...whi......
  • Python-09函数基础、形参、实参
    Python3函数函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段。函数能提高应用的模块性,和代码的重复利用率。你已经知道Python提供了许多内建函数,比如print......
  • redis核心数据结构与高性能原理
    一:redis安装1.下载wgethttp://download.redis.io/releases/redis-5.0.3.tar.gz 2.解压和编译tarxzfredis‐5.0.3.tar.gzcdredis‐5.0.3#进入到解压好的re......