问题是您的ID是一个浮点数,而不是整数(JavaScriptDate#getTime返回一个浮点数,我敢打赌MongoDB还将值存储为浮点数。)如果希望将其视为整数,则应转换JavaScript给您的值是Python代码中的整数:if request.method == "POST": try: # Remember, *never* trust user input # This is most likely a number but you are not guaranteed that data_id = int(request["id"]) except ValueError: abort(400) # If we got here, we have a valid int # Insert data into MongoDB