Python 相当于 QList c++ 的 join

Python equivalent of join for QList c++

本文关键字:join c++ QList 相当于 Python      更新时间:2023-10-16

我正在编写一个简单的文本编辑器,我有一个关键字列表,我在Python中定义如下:

keywords = [
   "action" ,
   "perform",
]

就像在 C++ 中一样

#define {
    QList<QString> keywords
    keywords.append("action");
    keywords.append("perform");
}; // Is this correct? I am trying to create a constant that would be a list of keywords

在 Python 中,我创建了一个与关键字匹配的正则表达式,如下所示:

keyword_match = r'b(' + r'|'.join(keywords) + r')b'

我的问题是,我怎样才能获得与 c++ 中的"join"相同的效果。

使用 QStringList ,它有一个join()方法。