简体   繁体   中英

Evaluate sympy expression on one variable out of two

I have a sympy expression with two variables

exp = x*y

I want to evaluate this function with y = 1 (to return a new expression new_exp = x)

I could only find the evalf function in the doc but it's not working (returns new_exp = x*y)

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

Any idea on this?

Thanks!

juste found out the sub function:

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

doing exactly the job

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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