How to overcome “datetime.datetime not JSON serializable”?

后端 未结 30 3243
梦谈多话
梦谈多话 2020-11-22 03:31

I have a basic dict as follows:

sample = {}
sample[\'title\'] = \"String\"
sample[\'somedate\'] = somedatetimehere
         


        
30条回答
  •  孤城傲影
    2020-11-22 04:01

    I faced this issue today, I found something called pickle. It's a built-in library for serializing python objects and also load it from a pickle file.

    The only difference I found between pickle and json is pickle file is a binary file, where as json is a usual text file.

    And It doesn't cause any issues with datetime objects.

提交回复
热议问题