Python can operate on MongoDB through Pymongo, but there is one point to note: MongoDB stored data is Bson format, and Bson requires data that must be a valid UTF8 type. Before we save the data to MongoDB, we need to make sure that the data is a valid UTF8 character, otherwise the insertion will go wrong. After reading the data from the MongoDB, it is processed according to the UTF8 format. However, the data type is Unicode when the data is read from the Pymongo and printed. This is because the Pymongo will decode the data from the MongoDB into Unicode, so when the data is read out, it is processed in Unicode, and the data is encoded into UTF8 more secure. Although Pymongo has such a layer of processing, but we turn the data into UTF8 storage to MongoDB, although also through the Pymongo, the data stored in the database is still utf8,pymongo just read out when doing such a conversion processing.
The following is an explanation of the official Pymongo document: