1. 程式人生 > 其它 >Python Redis 儲存hash型別資料value為list時報錯問題

Python Redis 儲存hash型別資料value為list時報錯問題

技術標籤:Pythonredis

Python Redis 儲存hash型別資料value為list時報錯問題

# 儲存一段hash到redis中,發現報錯
a = {"a": "111", "b": [1, 2, 3, 4]}
redis_store_3.hmset("111", a)

報錯資訊:
redis.exceptions.DataError: Invalid input of type: ‘list’. Convert to a bytes, string, int or float first.

在這裡插入圖片描述

檢視python的redis版本

在這裡插入圖片描述

此處降級版本到2.10.6即可

在這裡插入圖片描述

再次執行程式碼將成功執行