删除了嵌套表达式中的默认内容

2024-06-09 00:10:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Pyparsing模块和nestedExpr函数。你知道吗

我想给出一个定界符,而不是在nestedexpr函数的content参数中定界的默认空白。 如果我有下面这样的文字

text = "{{Infobox | birth_date = {{birth date and age|mf=yes|1981|1|31}}| birth_place = ((Memphis, Tennessee|Memphis)), ((Tennessee)), U.S.| instrument = ((Beatboxing)), guitar, keyboards, vocalsprint expr.parse| genre = ((Pop music|Pop)), ((contemporary R&B|R&B))| occupation = Actor, businessman, record producer, singer| years_active = 1992–present| label = ((Jive Records|Jive)), ((RCA Records|RCA)), ((Zomba Group of Companies|Zomba))| website = {{URL|xyz.com|Official website}} }}"

当我给出nestedExpr('{{','}}').parseString(text)时,我需要如下所示的输出:

['Infobox | birth_date =' ,['birth date and age|mf=yes|1981|1|31'],'| birth_place = ((Memphis, Tennessee|Memphis)), ((Tennessee)), U.S.| instrument = ((Beatboxing)), guitar, keyboards, vocalsprint expr.parse| genre = ((Pop music|Pop)), ((contemporary R&B|R&B))| occupation = Actor, businessman, record producer, singer| years_active = 1992–present| label = ((Jive Records|Jive)), ((RCA Records|RCA)), ((Zomba Group of Companies|Zomba))| website =',[ 'URL|xyz.com|Official website' ]]

如何将',''|'作为delimiter而不是空格分隔的字符?我试着给他们角色,但没用。你知道吗


Tags: and函数textdatewebsitepopbirthrecords