Python 3: Is not JSON serializable

后端 未结 2 2045
日久生厌
日久生厌 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

    This is not a string, but a byte sequence. JSON knows only how to handle Unicode strings, not byte sequences. Either transform into Unicode (json.dumps(x.decode("utf-8"))), or into an integer array (json.dumps(list(x))).

提交回复
热议问题