python安装rejson
Python代码
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 
 | 
 import rejson
 
 
 rj = rejson.Client(host='localhost', port=6379, decode_responses=True)
 
 def run():
 obj={}
 obj['a']="1"
 obj['b']="2"
 
 a = rj.jsonset('obj', '.', obj)
 
 
 b = rj.jsonget('obj', '.')
 print(b)
 return
 
 if __name__ == '__main__':
 run()
 
 
 | 
参数
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 
 | class Client(encoder=None, decoder=None, host: Text=..., port: int=..., db: int=..., password: Optional[Text]=..., socket_timeout: Optional[float]=...,
 socket_connect_timeout: Optional[float]=..., socket_keepalive: Optional[bool]=...,
 socket_keepalive_options: Optional[Mapping[str, Union[int, str]]]=...,
 connection_pool: Optional[ConnectionPool]=..., unix_socket_path: Optional[Text]=...,
 encoding: Text=..., encoding_errors: Text=..., charset: Optional[Text]=...,
 errors: Optional[Text]=..., decode_responses: bool=..., retry_on_timeout: bool=...,
 ssl: bool=..., ssl_keyfile: Optional[Text]=..., ssl_certfile: Optional[Text]=...,
 ssl_cert_reqs: Optional[Union[str, int]]=..., ssl_ca_certs: Optional[Text]=...,
 max_connections: Optional[int]=...,)
 
 | 
常用参数简单说明:
host redis地址
port redis端口
decode_responses=True 返回字符串
参考:
https://pypi.org/project/rejson/