pymongo的update操作为什么总不成功?
>>> kl Collection(Database(Connection('localhost', 27017), 'blog'), 'kl') >>> for d in kl.find(): ... print(d) ... {'title': 'my first blog', '_id': ObjectId('52a95f90663e8e1f03a20cec'), 'date': 'Thu Dec 12 14:49:15 2013', 'content': '试试中文'} {'title': 'my 2nd blog', '_id': ObjectId('52a963e1663e8e1f03a20ced'), 'date': 'Thu Dec 12 15:20:45 2013', 'content': '第二篇博文'}
>>> kl.update({'title':'my first blog'},{'$SET':{'content':'第一篇博文'}})
>>> for k in kl.find(): ... print(k) ... {'title': 'my first blog', '_id': ObjectId('52a95f90663e8e1f03a20cec'), 'date': 'Thu Dec 12 14:49:15 2013', 'content': '试试中文'} {'title': 'my 2nd blog', '_id': ObjectId('52a963e1663e8e1f03a20ced'), 'date': 'Thu Dec 12 15:20:45 2013', 'content': '第二篇博文'}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个。
自己顶下求指导~