擅长:python、mysql、java
<p>为了理解</p><pre>re.split(<em>pattern, string, maxsplit=0, flags=0</em>)</pre>在这里做什么,让我们看看{a1}:
<blockquote>
<p>Split <em>string</em> by the occurrences of <em>pattern</em>.</p>
</blockquote>
<p>因此,在您的示例中,您将查找文本中的所有<code>",* *\w*: "</code>,并将它们用作所需结果文本之间的分隔符。在</p>
<p>您正在使用的模式是查找任意数量的<code>,</code>,后跟任意数量的空白,任何数量的单词字符后跟{<cd3>}和一个空白。在</p>
<p>对于您的例子,这意味着:
<code><em>surname:</em> <strong>Obama</strong> <em>, prename:</em> <strong>Barack</strong> <em>, profession:</em> <strong>president</strong></code>
(斜体:分隔符,删除,粗体:列表的结果部分)。如您所见,在字符串的开头有一个匹配项,因此分割出一个空字符串<code>''</code>,后面是{<cd3>}后面的三个条目。这正是你的结果列表所说的。在</p>