问题
My Code is
configfile = open("abc.txt",'rb').read()
return base64.b64encode(configfile)
got error "Object of type 'bytes' is not JSON serializable in python3.6" on ec2
回答1:
Above issue appeared when i updated Django 1.8 to Django 2.2.6
I solve this by
Consider installing and using [simplejson][1], which can handle bytes strings in addition to unicode, to install it use command below:
pip3 install simplejson
Usage in code:
import simplejson as json
json.dumps({b'name': b'dev'})
This will solve JSON serializable issue.
来源:https://stackoverflow.com/questions/58452367/object-of-type-bytes-is-not-json-serializable-in-python3