gpt4 book ai didi

python - pyparsing如何从字符串创建语法对象

转载 作者:行者123 更新时间:2023-11-28 22:01:52 25 4
gpt4 key购买 nike

我在 DB 中为我的 pyparsing 应用程序提供语法。它们是字符串格式。我想在我的应用程序中将其转换为语法对象并开始使用它。

Word(alphas) + Word(nums)

上面的片段是我需要为其构造语法对象的数据库中的条目之一

谁能告诉我怎么实现

最佳答案

如果我没理解错的话,你可以使用eval或者exec。例如:

g = eval("Word(alphas) + Word(nums)")

关于python - pyparsing如何从字符串创建语法对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12506857/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com