python与redis的交互
#pip install redis import redis #1.链接数据库 key——value db=0 默认链接第0个数据库 client=redis.StrictRedis(host='127.0.0.1',port=6379) #2.设置key key='pyone' # #3.string 增加 :true/false # res=client.set(key,'1') # print(res) # #4.删 :1/0 # # res=client.delete(key) # # print(res) # # #5.改:就是重新设置 # res=client.set(key,'2') # print(res) #6.查看值:-bytes # res=client.get(key) # print(res) #查看所有的key: res=client.keys() print(res)