简体   繁体   English

在两个变量中的一个变量上评估 sympy 表达式

[英]Evaluate sympy expression on one variable out of two

I have a sympy expression with two variables我有一个带有两个变量的 sympy 表达式

exp = x*y

I want to evaluate this function with y = 1 (to return a new expression new_exp = x)我想用 y = 1 评估这个 function(返回一个新的表达式 new_exp = x)

I could only find the evalf function in the doc but it's not working (returns new_exp = x*y)我只能在文档中找到 evalf function 但它不起作用(返回 new_exp = x*y)

e.evalf(subs={y:1})

Any idea on this?对此有任何想法吗?

Thanks!谢谢!

juste found out the sub function: juste 发现了子 function:

https://www.geeksforgeeks.org/python-sympy-subs-method-2/ https://www.geeksforgeeks.org/python-sympy-subs-method-2/

doing exactly the job做正确的工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM