Python 中的 WolframClient:如何将 Wolframclient.evaluate 的输出转换为 sympy 表达式?
我在Python中使用了Wolframclient,在计算的某些点,我有以下输出
(Plus[-9, Times[2, Power[Global`y, 4]]], Plus[Times[3, Global`x], Times[-2, Power[Global`y, 3]]])
,现在需要将此输出转换为Sympy格式,类似方法
[-9 + 2*y**4, 3*x - 2*y**3]
可以做到这一点?
谢谢, 卢卡
I'm using wolframclient in Python and at certain point of my computation I have an output like the following
(Plus[-9, Times[2, Power[Global`y, 4]]], Plus[Times[3, Global`x], Times[-2, Power[Global`y, 3]]])
Now I need to convert this output into sympy format, something like
[-9 + 2*y**4, 3*x - 2*y**3]
Is there a way to do that?
Thanks,
Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mathematica解析器似乎不喜欢元组,因此,如果您可以将两个部分分开并用空字符串替换“全局”,则可以工作:
The mathematica parser doesn't seem to like the tuple, so if you can get the two parts separate and replace the "Global`" with a null string, it can work: