conn = RedisCluster(startup_nodes=nodes,
decode_responses=True, cluster_down_retry_attempts=20)
conn.hset('test','ab',"['122']")
print(conn.hgetall('test'))
print(eval(conn.hget('test','ab')))
輸出:
{
'ab': "['122']"}
['122']
如果[‘122’]用列表傳入則會報錯:
redis.exceptions.DataError: Invalid input of type: 'list'. Convert to a bytes, string, int or float first.