表达的结果如下:
Ellipse(Point(0,0),3,2)
Point(2.875, -0.661437827706861)
如果我想获取这些数字:0,0,3,2,2.875 ......有任何简单的方法可以获得它们吗?
答案 0 :(得分:2)
>>> from sympy import Ellipse, Point
>>> e = Ellipse(Point(0, 0), 3, 2)
>>> p, maj, min_ = e.args
>>> maj
3
>>> p
Point(0, 0)
>>> x, y = p.args
>>> x
0
答案 1 :(得分:1)
如果你只想要数字,你可以用原子(数字)得到它们:
>>> Point(2.875, -0.661437827706861).atoms(Number)
set([-661437827706861/1000000000000000, 23/8])
>>> Ellipse(Point(0, 0), 3, 2).atoms(Number)
set([0, 2, 3])
>>> Tuple(Point(2.875, -0.661437827706861), Ellipse(Point(0, 0), 3, 2)).atoms(
... Number)
set([0, 2, 3, -661437827706861/1000000000000000, 23/8])