Python DeprecationWarning 类型错误

升级pymongo模块到3.x的时候,产生了下面警告:
DeprecationWarning: update is deprecated. Use replace_one, update_one or update_many instead.

然后看了pymongo.collection.Collection.update方法

def update(self, spec, document, upsert=False, manipulate=False,
               multi=False, check_keys=True, **kwargs):
        """Update a document(s) in this collection.

        **DEPRECATED** - Use :meth:`replace_one`, :meth:`update_one`, or
        :meth:`update_many` instead.

        .. versionchanged:: 3.0
           Removed the `safe` parameter. Pass ``w=0`` for unacknowledged write
           operations.
        """
发现原来的update方法,被拆分成了replace_one,update_one,update_many三个方法,虽然没有错误,但是已经不赞成使用了,所以会抛出异常:
warnings.warn("update is deprecated. Use replace_one, update_one or "
                      "update_many instead.", DeprecationWarning, stacklevel=2)
然后查了一下资料, 该类型的警告大多属于版本更新时,所使用的方法过时的原因,可以在该方法的说明出查找替换的方法



你可能感兴趣的:(BUG,python)