Python 3: Is not JSON serializable

后端 未结 2 2046
日久生厌
日久生厌 2020-12-14 07:03
TypeError: b\'Pizza is a flatbread generally topped with tomato sauce and cheese and baked in an oven. It is commonly topped with a selection of meats, vegetables an         


        
2条回答
  •  悲&欢浪女
    2020-12-14 07:50

    Consider installing and using simplejson, 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'})
    

提交回复
热议问题