Python 保存redis哈希而不是字符串

Python 保存redis哈希而不是字符串,python,redis,Python,Redis,我可以在redis中将dict保存为字符串,如下所示: >>> r.set( 'rt.http://rottentomatoes.com/m/771354525/', {"Director": "blasco ricardo", "Platform": "RT"} ) 如何将dict直接保存为dict/hash,这样就不必使用json.loads将其读入dict?当前,如果我执行r.get()操作,我会将dic

我可以在redis中将dict保存为字符串,如下所示:

>>> r.set( 
           'rt.http://rottentomatoes.com/m/771354525/', 
           {"Director": "blasco ricardo", "Platform": "RT"}
         )
如何将dict直接保存为dict/hash,这样就不必使用
json.loads
将其读入dict?当前,如果我执行
r.get()
操作,我会将dict作为字符串获取:

>>> r.get('rt.http://rottentomatoes.com/m/771354525/')
'{"Director": "blasco ricardo", "Platform": "RT"}'
调查

然后,您可以使用

HGETALL rt.http://rottentomatoes.com/m/771354525/
或具有

HGET rt.http://rottentomatoes.com/m/771354525/ Director
在python中是这样的

r.hmset('rt.http://rottentomatoes.com/m/771354525/', {'Director': 'blasco ricardo', 'Platform': 'RT'})
r.hgetall('rt.http://rottentomatoes.com/m/771354525/')
r.hget('rt.http://rottentomatoes.com/m/771354525/', 'Director')
调查

然后,您可以使用

HGETALL rt.http://rottentomatoes.com/m/771354525/
或具有

HGET rt.http://rottentomatoes.com/m/771354525/ Director
在python中是这样的

r.hmset('rt.http://rottentomatoes.com/m/771354525/', {'Director': 'blasco ricardo', 'Platform': 'RT'})
r.hgetall('rt.http://rottentomatoes.com/m/771354525/')
r.hget('rt.http://rottentomatoes.com/m/771354525/', 'Director')