📅  最后修改于: 2022-03-11 14:46:04.832000             🧑  作者: Mango
expr = (Rational(-1, 2) * Z * k * (e**2) / r)
>>> expr
2
-Z⋅e ⋅k
ââââââââ
2⋅r
>>> ccode(expr)
-1.0/2.0*Z*pow(e, 2)*k/r
>>> from sympy.codegen.ast import real, float80
>>> ccode(expr, assign_to="E", type_aliases={real: float80})
E = -1.0L/2.0L*Z*powl(e, 2)*k/r;