a=dict(a=1,b=2,c=3)
r=redis.Redis()
r.set("haha",a)
r.hget("haha","b")#this will raise a exception
the right way is as follows:
r.hmset("haha",a)#attenation:when you use this approach,if you use r.set("haha",a) first,this also will occur a exception
r.hget("haha","b")

本文介绍如何正确使用Python字典与Redis进行数据交互的方法。通过示例说明了直接使用set方法会引发异常,并给出了正确的hmset方法用法及注意事项。
4万+

被折叠的 条评论
为什么被折叠?



