Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x python mongo db/如何有效地修改和删除字典中的列表?_Python 3.x_Mongodb_Pymongo 3.x - Fatal编程技术网

Python 3.x python mongo db/如何有效地修改和删除字典中的列表?

Python 3.x python mongo db/如何有效地修改和删除字典中的列表?,python-3.x,mongodb,pymongo-3.x,Python 3.x,Mongodb,Pymongo 3.x,这是来自Mongodb的数据 [ { '_id': ObjectId('5ae348f19268ff41a8e35170'), 'commission': [ {'_id': ObjectId('5ae348f19268ff41a8e35170'), 'commission': [

这是来自Mongodb的数据

[
         {
           '_id': ObjectId('5ae348f19268ff41a8e35170'),
           'commission': [
                            {'_id': ObjectId('5ae348f19268ff41a8e35170'),
                             'commission': [
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8a'), 'market': 'amazon_my', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8b'), 'market': 'amazon_sg', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2}
                                           ]
                            }
                         ]
         }
]
我想查找、插入、删除或更新除整个数据更改之外的一些我想要的数据。我已经找了好几件事,但我不知道如何有效地去做。请帮忙:)

____一,。插入数据____

[
         {
           '_id': ObjectId('5ae348f19268ff41a8e35170'),
           'commission': [
                            {'_id': ObjectId('5ae348f19268ff41a8e35170'),
                             'commission': [
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8a'), 'market': 'amazon_my', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8b'), 'market': 'amazon_sg', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                     ---inserted data       {'_id': ObjectId('cae21c969268ff4118df7f8b'), 'market': 'amazon_th', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2}
                                           ]
                            }
                         ]
         }
]
____二,。更新数据____

[
         {
           '_id': ObjectId('5ae348f19268ff41a8e35170'),
           'commission': [
                            {'_id': ObjectId('5ae348f19268ff41a8e35170'),
                             'commission': [
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8a'), 'market': 'amazon_my', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8b'), 'market': 'amazon_sg', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                     ___updated_commision   {'_id': ObjectId('cae21c969268ff4118df7f8b'), 'market': 'amazon_th', 'commission': 88.0, 'commission_vat': 0.24, 'payment': 2}
                                           ]
                            }
                         ]
         }
]
[
         {
           '_id': ObjectId('5ae348f19268ff41a8e35170'),
           'commission': [
                            {'_id': ObjectId('5ae348f19268ff41a8e35170'),
                             'commission': [
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8a'), 'market': 'amazon_my', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                                           ]
                            }
                         ]
         }
]
____三,。删除数据____

[
         {
           '_id': ObjectId('5ae348f19268ff41a8e35170'),
           'commission': [
                            {'_id': ObjectId('5ae348f19268ff41a8e35170'),
                             'commission': [
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8a'), 'market': 'amazon_my', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8b'), 'market': 'amazon_sg', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                     ___updated_commision   {'_id': ObjectId('cae21c969268ff4118df7f8b'), 'market': 'amazon_th', 'commission': 88.0, 'commission_vat': 0.24, 'payment': 2}
                                           ]
                            }
                         ]
         }
]
[
         {
           '_id': ObjectId('5ae348f19268ff41a8e35170'),
           'commission': [
                            {'_id': ObjectId('5ae348f19268ff41a8e35170'),
                             'commission': [
                                            {'_id': ObjectId('5ae21c969268ff4118df7f8a'), 'market': 'amazon_my', 'commission': 4.0, 'commission_vat': 0.24, 'payment': 2},
                                           ]
                            }
                         ]
         }
]

感谢阅读:)

如果以前这里没有人告诉过你,你可以一次问一个问题。不管怎样,你所有的问题都已经得到了回答,这就包括了在你发布任何东西之前“先搜索答案”。我还建议您阅读并花时间查看一些广受欢迎的问题和答案,作为您应该在此处提交的示例。这真的不适合那个简短的描述。谢谢你的回复。因为我还是一个初学者,我的英语很差。我会参考你的答案,让它更好一点。非常感谢,一切都很好。只是给你指出一些你可能还不知道的事情。