python redis数据库hash类型中value须是字符串

import redis

host = xxx

pwd = xxx

r = redis.Redis(host=host,password=pwd,db=15,decode_responses=True,port=xxxx)  

r.hmset('test',{'xxxxxx65': "{'QQ号': xxxxx65}"})   #写入redis

print(r.hgetall('test'))

#上述代码的执行结果:

{'xxxxxx65': "{'QQ号': xxxxx65}"}

#需要注意:

字典里value左右两边是 双引号,即value是个 字符串,非字典嵌套。

猜你喜欢

转载自www.cnblogs.com/xuexizongjie/p/10878992.html