Python JSON encoder to support datetime?

后端 未结 9 1886
长发绾君心
长发绾君心 2020-12-03 10:24

is there any elegant way to make Python JSON encoder support datetime? some 3rd party module or easy hack?

I am using tornado\'s database wrapper to fetch some rows

9条回答
  •  醉梦人生
    2020-12-03 10:58

    Convert the datetime type into a unix timestamp, then encode the contents into a json.

    e.g. : http://codepad.org/k3qF09Kr

提交回复
热议问题