【发布时间】:2018-08-12 02:42:41
【问题描述】:
尝试通过 Python3 设置 ReJSON。我在 Windows (WSL) 中的 Ubuntu 16.04 上运行,并且 Redis 和 ReJSON 正常工作。
已简化 https://github.com/RedisLabs/rejson-py 文档中的 python 以隔离问题:
from rejson import Client, Path
rj = Client(host='localhost', port=6379)
obj = {
'answer': 42,
'arr': [None, True, 3.14],
'truth': {
'coord': 'out there'
}
}
rj.jsonset('obj', Path.rootPath(), obj)
temp = rj.jsonget('obj', Path('.truth.coord'))
最后一行错误:
TypeError: cannot use a string pattern on a bytes-like object
我知道 obj 已经写好了,可以在 redis-cli 中看到:
127.0.0.1:6379> JSON.GET obj
"{\"answer\":42,\"arr\":[null,true,3.1400000000000001],\"truth\":{\"coord\":\"out there\"}}"
感谢任何帮助。
【问题讨论】: