2016-03-25 34 views
3
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 and condiments. The term was first recorded in the 10th century, in a Latin manuscript from Gaeta in Central Italy. The modern pizza was invented in Naples, Italy, and the dish and its variants have since become popular in many areas of the world.\nIn 2009, upon Italy\'s request, Neapolitan pizza was safeguarded in the European Union as a Traditional Speciality Guaranteed dish. The Associazione Verace Pizza Napoletana (the True Neapolitan Pizza Association) is a non-profit organization founded in 1984 with headquarters in Naples. It promotes and protects the "true Neapolitan pizza".\nPizza is sold fresh, frozen or in portions, and is a common fast food item in North America and the United Kingdom. Various types of ovens are used to cook them and many varieties exist. Several similar dishes are prepared from ingredients commonly used in pizza preparation, such as calzone and stromboli.' is not JSON serializable 

Bunu bir metin dizisine ekleyen bir JSON dizesine ekleyen bir programım var - ancak bu metin görünüşte değil. Neden olmasın ya da nasıl düzeltileceğini anlatabilir misin?Python 3: JSON serileştirilebilir değil

+0

'string = string.decode ('utf-8')'. – ekhumoro

cevap

8

Bu bir dize değil, bir bayt dizisidir. JSON, bayt dizileri değil, Unicode dizgilerini nasıl işleyeceğini bilir. Ya Unicode'a (json.dumps(x.decode("utf-8"))) veya bir tam sayı dizisine (json.dumps(list(x))) dönüştürebilirsiniz.

+0

Teşekkürler, işe yarıyor! – ReverseCold