Python 的 IMAP 库支持哪些线程算法?

What threading algorithm(s) does Python's IMAP library support?

imaplib 库中的 documentation for IMAP4.thread()

The thread command is a variant of search with threading semantics for the results. Returned data contains a space separated list of thread members.

Thread members consist of zero or more messages numbers, delimited by spaces, indicating successive parent and child.

Thread has two arguments before the search_criterion argument(s); a threading_algorithm, and the searching charset.

我不清楚 threading_algorithm 参数使用什么。该文档未指示默认值,并且 source code for the IMAP4.thread() function

def thread(self, threading_algorithm, charset, *search_criteria):
        """IMAPrev1 extension THREAD command.

        (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
        """

        name = 'THREAD'
        typ, dat = self._simple_command(name, threading_algorithm, charset, *search_criteria)
        return self._untagged_response(typ, dat, name)

也没有给我任何想法,即使在深入研究 _simple_command 辅助函数之后也是如此。

这个论点应该用什么?其他地方有这方面的文档吗?

这取决于服务器; CAPABILITIES 响应应该告诉您服务器支持哪些线程算法,在 THREAD= 键下。

例如:

* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION ID] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc.  See COPYING for distribution information.

此服务器支持 ORDEREDSUBJECT 和 REFERENCES 算法。

基线算法的描述在 IMAP SORT and THREAD RFC 中指示。

imaplib 是一个非常底层的库,您需要自己解析响应。