python - SymPy : Using Results of sympy.solve function
问题描述
I will try to use the result of solve function in sympy
from sympy import solve, expand,
SolutionForPi = (alpha*mu*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(-rho/(rho - 1) + 1) + f*mu)-pi
SolutionForPi = solve(SolutionForPi, pi)
The Result is
[mu*(-alpha*gamma*l*rho**2 + 2*alpha*gamma*l*rho - alpha*gamma*l - alpha*l*rho**2 + alpha*l*rho - f)/(alpha*gamma*mu*rho**2 - 2*alpha*gamma*mu*rho + alpha*gamma*mu + alpha*mu*rho**2 - alpha*mu*rho - 1)]
Then I use sympy.expend function
ExpandSolution = expand(SolutionForPi)
But I get this error :
AttributeError: 'list' object has no attribute 'expand'
What I understand is this is a list not an equation so what should I do ?
解决方案
如果您的解决方案封装在列表中,请访问(单个)列表成员
ExpandSolution = expand(SolutionForPi[0])
推荐阅读
- java - 自 Google Fit 应用程序更新以来 Google Fit 数据模式发生变化,实施明显中断
- reactjs - 是否可以根据组件状态打开菜单?在 react-native-popup-menu 中没有 MenuTrigger
- unix - Groovy:导出数据 - 如何设置从现在到过去某个时间点的 unix 开始时间?
- python - 使用欧几里得距离的 Numpy 数组的邻接矩阵
- javascript - 如何在 React 应用程序中正确使用 useSelector + createSelector(来自“重新选择”)?
- charts - 谷歌图表:隐藏超出 viewWindow 的点
- python - pymongo 转换。变量到字典中
- jpa - 部署后运行方法并将结果保存到数据库
- mysql - 如何将此 SQL 查询转换为使用 GROUP BY 和 HAVING 进行查询?
- vue.js - VueJs - Vuex - 改变状态