Pymongo中的isalpha()等效是什么?

发布于 2025-02-03 02:09:35 字数 347 浏览 1 评论 0原文

我在 pymongo中有一个字段,名称为“ processed_email_body ”。我如何检查它是否包含任何字母,基本上我的目标是找到空处理的电子邮件体的数量,因为空的封面仅包含点,而没有其他。因此,如果身体没有任何字母,我将继续增加计数。

到目前为止,我被困在这里:

iid = 11651704
database_69.user_emails.find({"Message_Id": iid, "Processing_Variables": {"Processed_Email_Body": }})

有什么想法要进一步吗?

I have a field in pymongo by the name "Processed_Email_Body". How do I check if it contains any letters or not, basically my objective is to find the count of empty processed email bodies, as the empty ones only contain dots and nothing else. So if the body does not have any letters, I will keep incrementing the count.

As of now I am stuck here:

iid = 11651704
database_69.user_emails.find({"Message_Id": iid, "Processing_Variables": {"Processed_Email_Body": }})

Any ideas to proceed further?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2025-02-10 02:09:35

这是一种使用 的文档。如果需要,您可以在过滤器中提供更多字段(例如,“ message_id”)。另请注意,您可能需要在python中“逃脱” “ $ REGEX”不同。

db.collection.find({
  "Processing_Variables.Processed_Email_Body": {
    "$regex": "^\\.+$",
    "$options": "m"
  }
})

尝试一下 mongoplayground.net.net

这是获取“空处理的电子邮件主体的计数”的一种方法。

db.collection.aggregate([
  {
    "$match": {
      "Processing_Variables.Processed_Email_Body": {
        "$regex": "^\\.+$",
        "$options": "m"
      }
    }
  },
  {
    "$count": "emptyBodiesCount"
  }
])

Here's one way to return docs with only . (one or more) in "Processing_Variables.Processed_Email_Body". You can provide more fields in the filter if you want (e.g., "Message_Id"). Also note that you may need to "escape" the . in the "$regex" differently in Python.

db.collection.find({
  "Processing_Variables.Processed_Email_Body": {
    "$regex": "^\\.+
quot;,
    "$options": "m"
  }
})

Try it on mongoplayground.net.

Here's a way to get the "count of empty processed email bodies".

db.collection.aggregate([
  {
    "$match": {
      "Processing_Variables.Processed_Email_Body": {
        "$regex": "^\\.+
quot;,
        "$options": "m"
      }
    }
  },
  {
    "$count": "emptyBodiesCount"
  }
])

Try this on mongoplayground.net.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文