文章内容

2020/8/26 10:08:49,作 者: 黄兵

redis.exceptions.DataError: Invalid input of type: 'bool'. Convert to a bytes, string, int or float first

今天在向Redis增加数据的时候,出现如下错误:

redis.exceptions.DataError: Invalid input of type: 'bool'. Convert to a bytes, string, int or float first.

出现错误的原因:

在向Redis插入数据的过程中,插入了bool值,所以出现错误。

具体代码:

if init_redis.hmset('phone_number:7114859',
{'create_time': '2020-7-31 0:00', 'enable': True}):

其中enable后面是一个bool值,所以出现了错误。

解决方案:

将bool值变成字符串,具体代码如下:

if init_redis.hmset('phone_number:7114859',
{'create_time': '2020-7-31 0:00', 'enable': str(True)}):


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - redis.exceptions.DataError: Invalid input of type: 'bool'. Convert to a bytes, string, int or float first

分享到:

发表评论

评论列表