import pyparsing as pp
print(pp.nestedExpr(opener="(", closer=")").parseString("(account={eq:T 1 No Lim})", parseAll=True)[0])
上面的代码给出了以下输出:
['account={eq:T', '1', 'No', 'Lim}']
但我想从值部分转义空格并想要以下输出:
[u'account={eq:T 1 No Lim}']
有人可以建议一下吗?
最佳答案
也许你可以利用originalTextFor
。
例如:
import pyparsing as pp
print(pp.originalTextFor(pp.nestedExpr(opener="(", closer=")")).parseString("(account={eq:T 1 No Lim})", parseAll=True)[0])
关于python - 在nestedExpr pyparsing中转义空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59626948/