gpt4 book ai didi

python - 如何显示 pymongo.errors.OperationFailure 详细信息?

转载 作者:可可西里 更新时间:2023-11-01 10:29:45 24 4
gpt4 key购买 nike

我在写入 MongoDB 时在 python 中遇到 pymongo OperationsFailure。除了回溯之外,是否有办法打印出详细信息或代码属性?

另见:http://api.mongodb.org/python/current/api/pymongo/errors.html#pymongo.errors.OperationFailure.details

到目前为止我正在使用:

try:
connection.test.foo.find_one()
except pymongo.errors.OperationFailure:
print "caught"

最佳答案

作品:

try:
connection.test.foo.find_one()
except pymongo.errors.OperationFailure as e:
print e.code
print e.details

关于python - 如何显示 pymongo.errors.OperationFailure 详细信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28407471/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com