First of all, the reason for the error is the datetime type field when exporting JSON.
Added in the code:
class dateencoder (JSON. Jsoneencoder):
Default (self, obj):
if isinstance (obj, datetime. Datetime):
return obj.strftime (“% Y -% m -% DT% H:% m:% s”)
else:
return json.jsoneencoder.default (self, obj)
Then add a CLS = dateencoder
in json.dump to solve the problem
As shown in the figure:
no error will be reported
Read More:
- Get the current date in Python
- Python json.dumps () json.dump The difference between ()
- close failed in file object destructor: IOError: [Error 10] No child processes
- Unexpected token u in JSON at position 0
- How to generate main () method in java graphical interface
- Type error: the JSON object must be STR, bytes or byte array, not ‘textiowrapper’
- RuntimeError: each element in
- Solution to unbalanced load of multiple cards (GPU’s 0 card is too high) in Python model training (simple and effective)
- ‘Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- @How to solve eclipse error after setter and @ getter (@ data) annotation
- In chome browser, console reports an error but does not display it
- SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
- Resttemplate Chinese garbled problem – available
- Springmvc Content type ‘application/json‘ not supported
- SLF4J: Class path contains multiple SLF4J bindings.
- Error converting data type nvarchar to datetime
- Get the height of mobile phone status bar through reflection
- An error 1064 is reported when pymysql accesses the image
- Error resolution of unexpected token in JSON at position 0
- The difference between “?” and “?:” introduced by php7