猿问

新的 sympy 交叉口用法

直到 1.3 版,这段代码运行良好:


from sympy import Intersection; 

from sympy import solveset; 

from sympy import S; from sympy.abc import x; 

from sympy.functions.elementary.miscellaneous import Min, Max; 

print Intersection([solveset(p, x, S.Reals) for p in [((((x + 2.0000) * 3.0000)+18.000000) > 0.000), ((((x + 2.0000) * 3.0000)+18.000000) < 1.000)]])

我不知道如何使用新的Intersection,cf https://github.com/sympy/sympy/pull/16344


慕婉清6462132
浏览 181回答 1
1回答

不负相思意

找到了解决方案:我必须使用 -operator 解压缩Intersection参数*:print&nbsp;Intersection(*[solveset(p,&nbsp;x,&nbsp;S.Reals)&nbsp;for&nbsp;p&nbsp;in&nbsp;[((((x&nbsp;+&nbsp;2.0000)&nbsp;*&nbsp;3.0000)+18.000000)&nbsp;>&nbsp;0.000),&nbsp;((((x&nbsp;+&nbsp;2.0000)&nbsp;*&nbsp;3.0000)+18.000000)&nbsp;<&nbsp;1.000)]])
随时随地看视频慕课网APP

相关分类

Python
我要回答