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.
我可以像这样评估 NumExpr 中的表达式
numexpr.evaluate('17 == b', local_dict={'b': 17})
我怎样才能得到里面的变量列表和表达式,'17 == b'然后我会得到['b']
'17 == b'
['b']
谢谢你。
也许可以以更简单的方式完成,但这对我有用
import numexpr.necompiler as nec print map(lambda x: x.value, nec.typeCompileAst(nec.expressionToAST(nec.stringToExpression(ex, {}, {}))).allOf('variable'))