pyparsing 创建PEG解析器Python库

pyparsing通用解析器的框架

pyparsing,Python通用解析器的框架,是Python的第三方库,是创建和执行简单语法的一种替代方法,而不是传统的lex/yacc方法或使用正则表达式。Python解析模块提供了一个类库,客户端代码使用该库直接在Python代码中构造语法。

pyparsing应用实例

import pyparsing as pp

greet = pp.Word(pp.alphas) + "," + pp.Word(pp.alphas) + "!"
for greeting_str in [
            "Hello, World!",
            "Bonjour, Monde!",
            "Hola, Mundo!",
            "Hallo, Welt!",
        ]:
    greeting = greet.parse_string(greeting_str)
    print(greeting)

Github开源协议和stars

MIT license

Github 2k stars

pyparsing安装命令

pip install pyparsing

Python版本要求

最近的版本要求Python3.6+

免责声明:内容编辑自网络,仅供参考,不保证正确性,不作任何决策依据!!以上数据皆截止于博文的写稿日期。


行业导航 / Python指南 :
























Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.