我有一个小的 json 文件,有以下几行:
{
"IdTitulo": "Jaws",
"IdDirector": "Steven Spielberg",
"IdNumber": 8,
"IdDecimal": "2.33"
}
Run Code Online (Sandbox Code Playgroud)
我的数据库集合中有一个模式,名为 test_dec。这是我用来创建架构的内容:
db.createCollection("test_dec",
{validator: {
$jsonSchema: {
bsonType: "object",
required: ["IdTitulo","IdDirector"],
properties: {
IdTitulo: {
"bsonType": "string",
"description": "string type, nombre de la pelicula"
},
IdDirector: {
"bsonType": "string",
"description": "string type, nombre del director"
},
IdNumber : {
"bsonType": "int",
"description": "number type to test"
},
IdDecimal : {
"bsonType": "decimal",
"description": "decimal type"
}
}
}}
})
Run Code Online (Sandbox Code Playgroud)
我已经多次尝试插入数据。问题出在 IdDecimal 字段值中。
一些试验,将 IdDecimal 行替换为:
"IdDecimal": …Run Code Online (Sandbox Code Playgroud) Consider the lists:
assigned = [4,8]
matching = [['B', [4, 5, 6]], ['C', [7, 8, 9]]]
Run Code Online (Sandbox Code Playgroud)
I am trying to remove given integers with the following code
for ii in range(len(assigned)):
while any(assigned[ii] in x for x in matching):
matching.remove(assigned[ii])
Run Code Online (Sandbox Code Playgroud)
I have two problems here. First one is to get into the inner lists. Right now the code does nothing because there is no matching.
Second problem, I tried this:
t = ['B', [4, 5, 6]]
if any(4 in x …Run Code Online (Sandbox Code Playgroud)