Python 无法将带有嵌套数组的dict对象插入MongoDB(pymongo)
我正在尝试将dict对象插入MongoDB。我正在python脚本中使用此代码Python 无法将带有嵌套数组的dict对象插入MongoDB(pymongo),python,arrays,mongodb,dictionary,insert,Python,Arrays,Mongodb,Dictionary,Insert,我正在尝试将dict对象插入MongoDB。我正在python脚本中使用此代码 result = centros.insert(clinica) 其中临床医生是dict对象 下面的值没有问题 { 'General details': { 'CCN': '1046002329', 'Regional Authorization Code of the Center': '5711', 'Name of Centre': '+ DENTAL
result = centros.insert(clinica)
其中临床医生是dict对象
下面的值没有问题
{
'General details': {
'CCN': '1046002329',
'Regional Authorization Code of the Center': '5711',
'Name of Centre': '+ DENTAL OLIVA S.C.P.',
'Autonomous Community': 'Comunitat Valenciana',
'Province': 'Valencia/València',
'Town/City': 'Oliva'
},
'Address': {
'Type of street': 'CALLE',
'Name of street': 'MONJAS CLARISAS',
'Number': '1',
'Postcode': '46780'
},
'Contact': {
'Email': 'DENTALBENIMACLET@HOTMAIL.COM',
'Telephone': '962854567'
},
'Type of Centre': {
'Type of Centre': 'C251 - Clínicas Dentales'
},
'Classification': {
'Authority or Organisation': 'Privados',
'Classification': 'Privados'
},
'Care Offered': {
**'Authorised Services': ['U.44 Odontología/Estomatología']**
},
'Administrative details': {
'Date Authorisation Received': '21/02/2005',
'Date of Last Authorisation': '10/09/2020',
'Most Recent Authorisation Type': 'Autorizacion de modificacion'
}
}
But if I try to insert this one, the insert fails :
{
'General details': {
'CCN': '0908000855',
'Regional Authorization Code of the Center': 'E08034627',
'Name of Centre': '+ SALUT DENTAL',
'Autonomous Community': 'Cataluña',
'Province': 'Barcelona',
'Town/City': 'Igualada'
},
'Address': {
'Type of street': 'AVENIDA',
'Name of street': 'BALMES',
'Number': '30',
'Postcode': '08700'
},
'Contact': {
'Email': 'SALUTDENTAL@SALUTDENTAL.CAT',
'URL.': 'WWW.SALUTDENTAL.CAT',
'Telephone': '938039232',
'Fax': '938067466'
},
'Type of Centre': {
'Type of Centre': 'C251 - Clínicas Dentales'
},
'Classification': {
'Authority or Organisation': 'Privados',
'Classification': 'Privados'
},
'Care Offered': {
**'Authorised Services': ['U.35 Anestesia y Reanimación', 'U.44 Odontología/Estomatología', 'U.84 Depósito de medicamentos']**
},
'Administrative details': {
'Date Authorisation Received': '30/09/1997',
'Date of Last Authorisation': '29/05/2018',
'Most Recent Authorisation Type': 'Autorizacion de modificacion'
}
}
它们之间的区别在于阵列“授权服务”中的元素数量。只要使用一个元素,插入就可以正常进行。如果有多个,则插入失败
我堆积在这里,找不到解释。插入失败,因为您有一个无效的字段
URL。
。字段名不能包含句点(
)
你的错误是什么?有关如何组织问题以获得最佳帮助的更多信息,请参阅。已解决,非常感谢
'URL.': 'WWW.SALUTDENTAL.CAT',