Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在为一些标记的数据编写解析器,我希望 pyparsing 在最终结果中丢弃诸如开始和结束标记之类的东西,只留下数据。
我可以这样做,还是我只需要适当地命名值并手动将它们拉出来?
“抑制”可能是您想要的。您可以显式使用 Suppress 类,如在dont_care = Suppress(Word(alphas))或在任何表达式上调用 suppress() dont_care = Word(alphas).suppress()。这将抑制匹配的标记出现在解析的输出中。
dont_care = Suppress(Word(alphas))
dont_care = Word(alphas).suppress()