11.redis_python

2020-09-17 10:37:26 浏览数 (1)

代码语言:javascript复制
# pip install redis

import redis

# 1.链接数据库 key--value
client = redis.StrictRedis(host='127.0.0.1', port=6379)

# 2.设置key
key = 'pyone'

# 3.string  增加
result = client.set(key, "1")

# 4.删 1, 0
result = client.delete(key)

# 5.改
result = client.set(key,'2')

# 6.查--bytes
result = client.get(key)

# 查看所有的键
result = client.keys()

print(result)

0 人点赞