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

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

I have a basic dict as follows:

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


        
30条回答
  •  隐瞒了意图╮
    2020-11-22 03:51

    My quick & dirty JSON dump that eats dates and everything:

    json.dumps(my_dictionary, indent=4, sort_keys=True, default=str)
    

提交回复
热议问题